| author | Christian Urban <christian.urban@kcl.ac.uk> | 
| Mon, 07 Sep 2020 12:27:08 +0100 | |
| changeset 755 | 40e890446213 | 
| parent 754 | 05a51fa5f7bb | 
| child 756 | cb2918e02806 | 
| permissions | -rw-r--r-- | 
| 631 | 1 | % !TEX program = xelatex | 
| 743 | 2 | \documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer}
 | 
| 252 
e8ef8f38ca84
added style files
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
215diff
changeset | 3 | \usepackage{../slides}
 | 
| 
e8ef8f38ca84
added style files
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
215diff
changeset | 4 | \usepackage{../graphics}
 | 
| 215 
828303e8e4af
updated slides
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
98diff
changeset | 5 | \usepackage{../langs}
 | 
| 
828303e8e4af
updated slides
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
98diff
changeset | 6 | \usepackage{../data}
 | 
| 0 | 7 | |
| 754 | 8 | \usepackage{tcolorbox}
 | 
| 9 | \newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black}
 | |
| 10 | \newtcolorbox{mybox2}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1}
 | |
| 11 | \newtcolorbox{mybox3}[1]{colback=Cyan!5!white,colframe=Cyan!75!black,fonttitle=\bfseries,title=#1}
 | |
| 12 | ||
| 743 | 13 | |
| 14 | ||
| 252 
e8ef8f38ca84
added style files
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
215diff
changeset | 15 | \hfuzz=220pt | 
| 
e8ef8f38ca84
added style files
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
215diff
changeset | 16 | |
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 17 | \lstset{language=Scala,
 | 
| 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 18 | style=mystyle, | 
| 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 19 | numbersep=0pt, | 
| 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 20 | numbers=none, | 
| 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 21 | xleftmargin=0mm} | 
| 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 22 | |
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 23 | \newcommand{\bl}[1]{\textcolor{blue}{#1}}     
 | 
| 559 | 24 | |
| 0 | 25 | % beamer stuff | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 26 | \renewcommand{\slidecaption}{CFL 01, King's College London}
 | 
| 0 | 27 | |
| 721 
e712943cff71
added slides from Rochester
 Christian Urban <christian.urban@kcl.ac.uk> parents: 
637diff
changeset | 28 | %% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect1/main.pdf | 
| 
e712943cff71
added slides from Rochester
 Christian Urban <christian.urban@kcl.ac.uk> parents: 
637diff
changeset | 29 | %% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect2/main.pdf | 
| 
e712943cff71
added slides from Rochester
 Christian Urban <christian.urban@kcl.ac.uk> parents: 
637diff
changeset | 30 | %% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect3/main.pdf | 
| 0 | 31 | |
| 32 | \begin{document}
 | |
| 33 | ||
| 754 | 34 | \begin{frame}[t]
 | 
| 35 | \begin{mybox}
 | |
| 36 | A physical explanation the \emph{dynamic matrix}\\
 | |
| 37 | lots of text | |
| 38 | \end{mybox}
 | |
| 743 | 39 | |
| 40 | ||
| 754 | 41 | \begin{mybox2}{Test}
 | 
| 42 | A physical explanation the \emph{dynamic matrix}\\
 | |
| 43 | lots of text | |
| 44 | \end{mybox2}
 | |
| 45 | ||
| 46 | \begin{mybox3}{Test}
 | |
| 47 | A physical explanation the \emph{dynamic matrix}\\
 | |
| 48 | lots of text | |
| 49 | \end{mybox3}
 | |
| 50 | \end{frame}
 | |
| 51 | ||
| 0 | 52 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 53 | \begin{frame}[t]
 | 
| 510 | 54 | \frametitle{%  
 | 
| 0 | 55 |   \begin{tabular}{@ {}c@ {}}
 | 
| 1 | 56 | \\[-3mm] | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 57 | \LARGE Compilers and \\[-1mm] | 
| 743 | 58 | \LARGE Formal Languages\\[-3mm] | 
| 0 | 59 |   \end{tabular}}
 | 
| 60 | ||
| 61 |   \begin{center}
 | |
| 507 | 62 |   %\includegraphics[scale=0.3]{pics/ante1.jpg}\hspace{5mm}
 | 
| 63 |   %\includegraphics[scale=0.31]{pics/ante2.jpg}\\
 | |
| 64 |   %\footnotesize\textcolor{gray}{Antikythera automaton, 100 BC (Archimedes?)}
 | |
| 0 | 65 |   \end{center}
 | 
| 66 | ||
| 510 | 67 | \normalsize | 
| 0 | 68 |   \begin{center}
 | 
| 69 |   \begin{tabular}{ll}
 | |
| 70 | Email: & christian.urban at kcl.ac.uk\\ | |
| 743 | 71 | %Office Hours: & Thursdays 12 -- 14\\ | 
| 72 | %Location: & N7.07 (North Wing, Bush House)\\ | |
| 631 | 73 | Slides \& Progs: & KEATS\\ | 
| 0 | 74 |   \end{tabular}
 | 
| 75 |   \end{center}
 | |
| 76 | ||
| 743 | 77 |   \begin{center}
 | 
| 78 |     \begin{tikzpicture}
 | |
| 79 | \node[drop shadow,fill=white,inner sep=0pt] | |
| 80 |       {\footnotesize\rowcolors{1}{capri!10}{white}
 | |
| 81 |         \begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline
 | |
| 82 |           \cellcolor{blue!50}
 | |
| 83 | 1 Introduction, Languages & 6 While-Language \\ | |
| 84 | 2 Regular Expressions, Derivatives & 7 Compilation, JVM \\ | |
| 85 | 3 Automata, Regular Languages & 8 Compiling Functional Languages \\ | |
| 86 | 4 Lexing, Tokenising & 9 Optimisations \\ | |
| 87 | 5 Grammars, Parsing & 10 LLVM \\ \hline | |
| 88 |         \end{tabular}%
 | |
| 89 | }; | |
| 90 |     \end{tikzpicture}
 | |
| 91 |   \end{center}
 | |
| 92 | ||
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 93 | \end{frame}
 | 
| 559 | 94 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 0 | 95 | |
| 96 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 744 | 97 | \begin{frame}<1-11>[c]
 | 
| 98 | \frametitle{The Goal of this Module\ldots}
 | |
| 99 | ||
| 100 | \begin{center}
 | |
| 101 |   \begin{tikzpicture}[scale=1,
 | |
| 102 |                       node/.style={
 | |
| 103 | rectangle,rounded corners=3mm, | |
| 104 | very thick,draw=black!50,minimum height=18mm, minimum width=20mm, | |
| 105 | top color=white,bottom color=black!20,drop shadow}] | |
| 106 | ||
| 107 |   \node at (3.05, 1.8) {\Large\bf \ldots{} you write a compiler};
 | |
| 108 | ||
| 109 |   \node (0) at (-2.3,0) {};  
 | |
| 110 | \node [above=5mm of 0] | |
| 111 |   {\makebox[0mm]{\footnotesize
 | |
| 112 |       \begin{tabular}{@{}l@{}}input\\[-1mm]program\end{tabular}}}; 
 | |
| 113 | ||
| 114 |   \node (A) at (0,0)  [node] {};
 | |
| 115 |   \node [below right] at (A.north west) {lexer};
 | |
| 116 | ||
| 117 |   \node (B) at (3,0)  [node] {};
 | |
| 118 |   \node [below right=1mm] at (B.north west) {\mbox{}\hspace{-1mm}parser};
 | |
| 119 | ||
| 120 |   \node (C) at (6,0)  [node] {};
 | |
| 121 |   \node [below right] at (C.north west) {\mbox{}\hspace{-1mm}code gen};
 | |
| 122 | ||
| 123 |   \node (1) at (8.4,0) {};
 | |
| 124 | \node [above=5mm of 1] | |
| 125 |   {\makebox[0mm]{\footnotesize
 | |
| 126 |       \begin{tabular}{@{}r@{}}binary\\[-1mm]code\end{tabular}}};
 | |
| 127 | ||
| 128 | \draw [->,line width=4mm] (0) -- (A); | |
| 129 | \draw [->,line width=4mm] (A) -- (B); | |
| 130 | \draw [->,line width=4mm] (B) -- (C); | |
| 131 | \draw [->,line width=4mm] (C) -- (1); | |
| 132 |   \end{tikzpicture}
 | |
| 133 |   \end{center}
 | |
| 134 | ||
| 135 | \only<2,3,4>{
 | |
| 136 | \begin{textblock}{1}(1,2.1)
 | |
| 137 | \begin{bubble}[9.8cm]
 | |
| 138 | \normalsize | |
| 139 | lexer input: a string\smallskip\\ | |
| 140 | \hspace{5mm}\code{"read(n);"}\medskip\\
 | |
| 141 | lexer output: a sequence of tokens\smallskip\\ | |
| 142 | \hspace{5mm}\code{key(read) lpar id(n) rpar semi}
 | |
| 143 | \end{bubble}
 | |
| 144 | \end{textblock}} 
 | |
| 145 | ||
| 146 | \only<3,4>{
 | |
| 147 | \begin{textblock}{1}(6,7.8)
 | |
| 148 | \begin{tabular}{c}
 | |
| 149 | \includegraphics[scale=0.2]{../pics/rosetta.jpg}\\[-2mm]
 | |
| 150 | \footnotesize lexing $\Rightarrow$ recognising words (Stone of Rosetta) | |
| 151 | \end{tabular}
 | |
| 152 | \end{textblock}}
 | |
| 153 | ||
| 154 | \only<4>{
 | |
| 155 | \begin{textblock}{1}(0.5,12)\small
 | |
| 156 | \begin{tabular}{l@{}c@{}l}
 | |
| 157 |   \pcode{if}    & $\;\Rightarrow\;$ & keyword\\
 | |
| 158 |   \pcode{iffoo} & $\;\Rightarrow\;$ & identifier\\
 | |
| 159 | \end{tabular}  
 | |
| 160 | \end{textblock}}
 | |
| 161 | ||
| 162 | \only<6>{
 | |
| 163 | \begin{textblock}{1}(1,1.5)
 | |
| 164 | \begin{bubble}[8.5cm]
 | |
| 165 | \normalsize | |
| 166 | parser input: a sequence of tokens\smallskip\\ | |
| 167 | ||
| 168 | {\small\hspace{5mm}\code{key(read) lpar id(n) rpar semi}}\smallskip\\
 | |
| 169 | ||
| 170 | parser output: an abstract syntax tree\smallskip\\ | |
| 171 | \footnotesize | |
| 172 | \hspace{2cm}\begin{tikzpicture}
 | |
| 173 |   \node {\code{read}}
 | |
| 174 |     child {node {\code{lpar}}}
 | |
| 175 |     child {node {\code{n}}}
 | |
| 176 |     child {node {\code{rpar}}};
 | |
| 177 | \end{tikzpicture}
 | |
| 178 | \end{bubble}
 | |
| 179 | \end{textblock}}
 | |
| 180 | ||
| 181 | \only<8,9>{
 | |
| 182 | \begin{textblock}{1}(1,1.5)
 | |
| 183 | \begin{bubble}[4cm]
 | |
| 184 | \normalsize | |
| 185 | code generation:\smallskip\\ | |
| 186 | \hspace{5mm}\code{istore 2}\\ 
 | |
| 187 | \hspace{5mm}\code{iload 2}\\ 
 | |
| 188 | \hspace{5mm}\code{ldc 10}\\
 | |
| 189 | \hspace{5mm}\code{isub}\\
 | |
| 190 | \hspace{5mm}\code{ifeq Label2}\\ 
 | |
| 191 | \hspace{5mm}\code{iload 2}\\
 | |
| 192 | \hspace{5mm}\code{...}\\
 | |
| 193 | \end{bubble}
 | |
| 194 | \end{textblock}}
 | |
| 195 | ||
| 196 | \only<9>{
 | |
| 197 | \begin{textblock}{6}(8.4,7)
 | |
| 198 | \begin{bubble}[5cm]
 | |
| 199 | \mbox{\begin{tikzpicture}[scale=0.58,rounded corners=0mm]
 | |
| 200 | \begin{axis}[axis x line=bottom, axis y line=left, ylabel=secs,
 | |
| 201 | xlabel=n, | |
| 202 | enlargelimits=0.05, | |
| 203 | ybar interval=0.7, legend style=small] | |
| 204 | \addplot file {interpreted2.data};
 | |
| 205 | \addplot file {compiled2.data};
 | |
| 206 | %\legend{interpreted, compiled}
 | |
| 207 | \end{axis}
 | |
| 208 | \end{tikzpicture}}
 | |
| 209 | \end{bubble}
 | |
| 210 | \end{textblock}}
 | |
| 211 | ||
| 212 | \only<10>{
 | |
| 213 | \begin{textblock}{6}(1,3)
 | |
| 214 |   \begin{bubble}[11cm]
 | |
| 215 |   Compiler explorers, e.g.: \url{https://gcc.godbolt.org}  
 | |
| 216 |   \begin{tikzpicture}[]
 | |
| 217 |   \node (0) at (-2.3,0) {\includegraphics[scale=0.3]{pics/csource.png}};
 | |
| 218 |   \node (1) [right=35mm] at (0) {\includegraphics[scale=0.3]{pics/cassmbl.png}}; 
 | |
| 219 | \draw [->,line width=4mm, red] (0) -- (1); | |
| 220 |   \node (2) [below=20mm] at (0) {\LARGE\bf``source''};
 | |
| 221 |   \node (3) [right=40mm] at (2) {\LARGE\bf``binary''};
 | |
| 222 | \draw [->,line width=1mm] (2) -- (3); | |
| 223 | \end{tikzpicture}
 | |
| 224 | \end{bubble}
 | |
| 225 | \end{textblock}}
 | |
| 226 | ||
| 227 | ||
| 228 | \end{frame}
 | |
| 229 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 230 | ||
| 231 | ||
| 232 | ||
| 233 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 559 | 234 | \begin{frame}[t]
 | 
| 235 | \frametitle{Why Study Compilers?}
 | |
| 0 | 236 | |
| 743 | 237 | |
| 238 | John Regehr {\small(Univ.~Utah, LLVM compiler hacker)}
 | |
| 239 | \here{https://blog.regehr.org/archives/1419}
 | |
| 240 | \smallskip\\ | |
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 241 | |
| 559 | 242 | \begin{bubble}[10.5cm]
 | 
| 243 |   \bf ``\ldots{}It’s effectively a perpetual
 | |
| 244 | employment act for solid compiler hackers.'' | |
| 245 | \end{bubble}
 | |
| 0 | 246 | |
| 559 | 247 | \onslide<1->{
 | 
| 248 | \only<2>{
 | |
| 249 | \begin{itemize}
 | |
| 250 | \item {\bf Hardware is getting weirder
 | |
| 631 | 251 | rather than getting clocked faster.} | 
| 0 | 252 | |
| 559 | 253 | \begin{itemize}
 | 
| 631 | 254 | \item[] ``Almost all processors are multicores nowadays and it looks | 
| 255 | like there is increasing asymmetry in resources across cores. | |
| 256 | Processors come with vector units, crypto accelerators etc. We have | |
| 257 | DSPs, GPUs, ARM big.little, and Xeon Phi. This is only scratching the | |
| 258 | surface.'' | |
| 559 | 259 | \end{itemize}  
 | 
| 260 | \end{itemize}}
 | |
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 261 | \only<3>{
 | 
| 559 | 262 | \begin{itemize}
 | 
| 263 | \item {\bf We’re getting tired of low-level languages and
 | |
| 631 | 264 | their associated security disasters.} | 
| 559 | 265 | |
| 266 | \begin{itemize}
 | |
| 631 | 267 | \item [] ``We want to write new code, to whatever extent possible, in | 
| 268 | safer, higher-level languages. Compilers are caught right in the | |
| 269 | middle of these opposing trends: one of their main jobs is to help | |
| 270 | bridge the large and growing gap between increasingly high-level | |
| 271 | languages and increasingly wacky platforms.'' | |
| 559 | 272 | \end{itemize}  
 | 
| 273 | \end{itemize}}}
 | |
| 1 | 274 | |
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 275 | \end{frame}
 | 
| 0 | 276 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 1 | 277 | |
| 631 | 278 | |
| 279 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 280 | \begin{frame}[c]
 | |
| 744 | 281 | \frametitle{Why Bother with Compilers?}
 | 
| 631 | 282 | |
| 745 | 283 | \textbf{Boeing 777's}: First flight in 1994. They want to achieve
 | 
| 284 | triple redundancy for potential hardware faults. | |
| 285 | \here{http://www.citemaster.net/get/db3a81c6-548e-11e5-9d2e-00163e009cc7/R8.pdf}\bigskip
 | |
| 631 | 286 | |
| 287 | They compile 1 Ada program to\medskip | |
| 288 | ||
| 289 | \begin{itemize}
 | |
| 290 | \item Intel 80486 | |
| 291 | \item Motorola 68040 (old Macintosh's) | |
| 292 | \item AMD 29050 (RISC chips used often in laser printers) | |
| 293 | \end{itemize}\medskip\medskip
 | |
| 294 | ||
| 295 | using 3 independent compilers.\bigskip\pause | |
| 296 | ||
| 297 | \small Airbus uses C and static analysers. Recently started using CompCert. | |
| 745 | 298 | |
| 299 | \only<1->{%
 | |
| 300 | \begin{textblock}{6}(8,4.5)
 | |
| 301 | \includegraphics[scale=0.28]{../pics/777.png}
 | |
| 302 | \end{textblock}}
 | |
| 303 | ||
| 631 | 304 | \end{frame}
 | 
| 305 | %%%%%%%%%%% | |
| 306 | ||
| 307 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 308 | \begin{frame}[c]
 | 
| 745 | 309 | \frametitle{Why Bother with Regexes?}
 | 
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 310 | |
| 745 | 311 | \begin{columns}[t,onlytextwidth]
 | 
| 312 | \begin{column}{1.8cm}
 | |
| 313 | \mbox{}   
 | |
| 314 | \end{column}    
 | |
| 315 | \begin{column}{.5\textwidth}
 | |
| 316 | \small{}Ruby, Python, Java 8\medskip\\
 | |
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 317 | \begin{tikzpicture}\footnotesize
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 318 | \begin{axis}[
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 319 |     xlabel={$n$},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 320 |     x label style={at={(1.05,0.0)}},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 321 |     ylabel={time in secs},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 322 | enlargelimits=false, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 323 |     xtick={0,5,...,30},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 324 | xmax=33, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 325 | ymax=35, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 326 |     ytick={0,5,...,30},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 327 | scaled ticks=false, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 328 | axis lines=left, | 
| 745 | 329 | width=\textwidth, | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 330 | height=4cm, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 331 |     legend entries={Python,Ruby},  
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 332 | legend pos=north west, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 333 | legend cell align=left] | 
| 559 | 334 | \addplot[blue,mark=*, mark options={fill=white}] table {re-python.data};
 | 
| 335 | \addplot[brown,mark=triangle*, mark options={fill=white}] table {re-ruby.data};
 | |
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 336 | \end{axis}
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 337 | \end{tikzpicture}
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 338 | \begin{tikzpicture}\footnotesize
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 339 | \begin{axis}[
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 340 |     xlabel={$n$},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 341 |     x label style={at={(1.05,0.0)}},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 342 |     ylabel={time in secs},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 343 | enlargelimits=false, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 344 |     xtick={0,5,...,30},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 345 | xmax=33, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 346 | ymax=35, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 347 |     ytick={0,5,...,30},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 348 | scaled ticks=false, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 349 | axis lines=left, | 
| 745 | 350 | width=\textwidth, | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 351 | height=4cm, | 
| 631 | 352 |     legend entries={Python, Java 8, JavaScript},  
 | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 353 | legend pos=north west, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 354 | legend cell align=left] | 
| 559 | 355 | \addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};   
 | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 356 | \addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
 | 
| 631 | 357 | \addplot[red,mark=*, mark options={fill=white}] table {re-js.data};
 | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 358 | \end{axis}
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 359 | \end{tikzpicture}
 | 
| 745 | 360 | % | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 361 | \end{column}
 | 
| 745 | 362 | \begin{column}{.5\textwidth}
 | 
| 363 | \small{}Us (after next lecture)\medskip\\
 | |
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 364 | \begin{tikzpicture}\footnotesize
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 365 | \begin{axis}[
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 366 |     xlabel={$n$},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 367 |     x label style={at={(1.07,0.0)}},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 368 |     ylabel={time in secs},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 369 | enlargelimits=false, | 
| 442 
84d6714840c9
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
437diff
changeset | 370 |     xtick={0,5000,...,10000},
 | 
| 
84d6714840c9
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
437diff
changeset | 371 | xmax=11000, | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 372 | ymax=35, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 373 |     ytick={0,5,...,30},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 374 | scaled ticks=false, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 375 | axis lines=left, | 
| 745 | 376 | width=\textwidth, | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 377 | height=4cm] | 
| 437 
fe387fcbf2ee
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
428diff
changeset | 378 | \addplot[green,mark=square*,mark options={fill=white}] table {re2.data};
 | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 379 | \addplot[black,mark=square*,mark options={fill=white}] table {re3.data};
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 380 | \end{axis}
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 381 | \end{tikzpicture}
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 382 | \begin{tikzpicture}\footnotesize
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 383 | \begin{axis}[
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 384 |     xlabel={$n$},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 385 |     x label style={at={(1.07,0.0)}},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 386 |     ylabel={time in secs},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 387 | enlargelimits=false, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 388 | ymax=35, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 389 |     ytick={0,5,...,30},
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 390 | scaled ticks=false, | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 391 | axis lines=left, | 
| 745 | 392 | width=\textwidth, | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 393 | height=4cm] | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 394 | \addplot[black,mark=square*,mark options={fill=white}] table {re3a.data};
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 395 | \end{axis}
 | 
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 396 | \end{tikzpicture}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 397 | \end{column}
 | 
| 745 | 398 | \end{columns}
 | 
| 399 | \medskip | |
| 400 | ||
| 401 | \begin{textblock}{3}(-0.1,3.3)
 | |
| 402 | \small\hfill\bl{\texttt{[a?]\{n\}[a]\{n\}}}:
 | |
| 403 | \end{textblock}
 | |
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 404 | |
| 745 | 405 | \begin{textblock}{3}(-0.1,8.7)  
 | 
| 406 | \small\hfill\bl{\texttt{(a*)*b}}:
 | |
| 407 | \end{textblock}
 | |
| 408 | ||
| 409 | \begin{textblock}{3}(0.3,13)
 | |
| 410 | \small{}matching with strings
 | |
| 411 | \bl{$\underbrace{\texttt{a}...\texttt{a}}_n$}  
 | |
| 412 | \end{textblock}
 | |
| 413 | ||
| 510 | 414 | \end{frame} 
 | 
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 415 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 631 | 416 | |
| 417 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 418 | \begin{frame}[c,fragile]
 | |
| 419 |   \frametitle{Incidents}
 | |
| 420 | ||
| 421 |   \begin{itemize}
 | |
| 422 |   \item a global outage on 2 July 2019 at \textbf{Cloudflare} 
 | |
| 423 | (first one for six years)\medskip | |
| 424 | ||
| 425 |   \begin{center}\small\color{blue}
 | |
| 426 |   \begin{verbatim}  
 | |
| 427 | (?:(?:\"|'|\]|\}|\\|\d|(?:nan|infinity|true|false| | |
| 428 | null|undefined|symbol|math)|\`|\-|\+)+[)]*;?((?:\s | |
| 429 |   |-|~|!|{}|\|\||\+)*.*(?:.*=.*)))  
 | |
| 430 |   \end{verbatim}
 | |
| 431 |   \end{center}\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip    
 | |
| 432 | ||
| 433 |   \item on 20 July 2016 the \textbf{Stack Exchange} webpage went down
 | |
| 745 | 434 | because of an evil regular expression | 
| 435 |     \here{https://stackstatus.net/post/147710624694/outage-postmortem-july-20-2016}    
 | |
| 631 | 436 |   \end{itemize}
 | 
| 437 | ||
| 745 | 438 |   \begin{textblock}{6}(6,7.6)
 | 
| 728 | 439 |     \includegraphics[scale=0.14]{../pics/cloudflare.png}\\
 | 
| 631 | 440 | \footnotesize | 
| 745 | 441 | It serves more web traffic than Twitter, Amazon, Apple, | 
| 442 | Instagram, Bing \& Wikipedia combined. | |
| 443 |     \here{https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019/}
 | |
| 631 | 444 |     \end{textblock}
 | 
| 445 | ||
| 446 |   \end{frame}
 | |
| 447 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 448 | ||
| 560 | 449 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 450 | \begin{frame}[c]
 | |
| 451 | \frametitle{Evil Regular Expressions}
 | |
| 452 | ||
| 453 | \begin{itemize}
 | |
| 454 | \item \alert{R}egular \alert{e}xpression \alert{D}enial \alert{o}f \alert{S}ervice (ReDoS)\medskip
 | |
| 745 | 455 | \item Some evil regular expressions:\medskip | 
| 560 | 456 | \begin{itemize}
 | 
| 745 | 457 | \item \bl{\texttt{[a?]\{n\}\;[a]\{n\}}}
 | 
| 458 | \item \bl{\texttt{(a*)*\;b}}  
 | |
| 459 | \item \bl{\texttt{([a-z]+)*}} 
 | |
| 460 | \item \bl{\texttt{(a + aa)*}}
 | |
| 461 | \item \bl{\texttt{(a + a?)*}}
 | |
| 560 | 462 | \end{itemize}
 | 
| 463 | ||
| 464 | \item sometimes also called \alert{catastrophic backtracking}
 | |
| 465 | \item this is a problem for \alert{N}etwork \alert{I}ntrusion
 | |
| 631 | 466 |   \alert{D}etection systems, Cloudflare, StackExchange, Atom editor
 | 
| 560 | 467 | \item \url{https://vimeo.com/112065252}  
 | 
| 468 | \end{itemize}
 | |
| 469 | ||
| 470 | \end{frame}
 | |
| 471 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 472 | |
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 473 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 745 | 474 | \begin{frame}[t]
 | 
| 559 | 475 | \frametitle{The Acad.~Subject is Mature}
 | 
| 476 | ||
| 631 | 477 | \bigskip | 
| 559 | 478 | \begin{itemize}
 | 
| 631 | 479 | \item Turing Machines, 1936 (a tape as memory) | 
| 559 | 480 | \item Regular Expressions, 1956\\ | 
| 631 | 481 | \item The first compiler for COBOL, 1957\\ (Grace Hopper)\medskip | 
| 559 | 482 | \item But surprisingly research papers are still published nowadays\\ | 
| 483 | \item ``Parsing: The Solved Problem That Isn't'' | |
| 745 | 484 |   \here{https://tratt.net/laurie/blog/entries/parsing_the_solved_problem_that_isnt.html}
 | 
| 559 | 485 | \end{itemize}
 | 
| 486 | ||
| 745 | 487 | |
| 488 | \begin{textblock}{8.5}(5,7.6)
 | |
| 559 | 489 | \begin{flushright}
 | 
| 490 | \includegraphics[scale=0.3]{pics/hopper.jpg}\\
 | |
| 745 | 491 | \footnotesize\textcolor{gray}{Grace Hopper}\smallskip\\
 | 
| 559 | 492 | |
| 745 | 493 | {\small\textcolor{gray}{(she made it to David Letterman's Tonight Show
 | 
| 494 |  \here{https://youtu.be/3N_ywhx6_K0?t=31})}}
 | |
| 559 | 495 | \end{flushright}
 | 
| 745 | 496 | \end{textblock}
 | 
| 559 | 497 | |
| 498 | \end{frame}
 | |
| 499 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 500 | ||
| 632 | 501 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 502 | \begin{frame}[c]
 | |
| 745 | 503 | \frametitle{What Do Compilers Do?}
 | 
| 504 | ||
| 505 | Remember BF*** from PEP? | |
| 559 | 506 | |
| 632 | 507 | \begin{center}
 | 
| 508 | \begin{tabular}{lcl}
 | |
| 509 | \bl{\texttt{>}} & $\Rightarrow$ & move one cell right\\
 | |
| 510 | \bl{\texttt{<}} & $\Rightarrow$ & move one cell left\\
 | |
| 511 | \bl{\texttt{+}} & $\Rightarrow$ & increase cell by one\\
 | |
| 512 | \bl{\texttt{-}} & $\Rightarrow$ & decrease cell by one\\
 | |
| 513 | \bl{\texttt{.}} & $\Rightarrow$ & print current cell\\
 | |
| 514 | \bl{\texttt{,}} & $\Rightarrow$ & input current cell\\
 | |
| 515 | \bl{\texttt{[}} & $\Rightarrow$ & loop begin\\
 | |
| 516 | \bl{\texttt{]}} & $\Rightarrow$ & loop end\medskip\\
 | |
| 517 | & $\Rightarrow$ & everything else is a comment\\ | |
| 518 | \end{tabular}  
 | |
| 519 | \end{center}  
 | |
| 520 | ||
| 521 | \end{frame}
 | |
| 522 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 523 | ||
| 524 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 525 | \begin{frame}[c]
 | |
| 745 | 526 |   \frametitle{A ``Compiler'' for BF*** to C}
 | 
| 632 | 527 | |
| 528 |   \begin{center}
 | |
| 529 |   \begin{tabular}{lcl}
 | |
| 530 |   \bl{\texttt{>}} & $\Rightarrow$ & \texttt{ptr++}\\
 | |
| 531 |   \bl{\texttt{<}} & $\Rightarrow$ & \texttt{ptr--}\\
 | |
| 532 |   \bl{\texttt{+}} & $\Rightarrow$ & \texttt{(*ptr)++}\\
 | |
| 533 |   \bl{\texttt{-}} & $\Rightarrow$ & \texttt{(*ptr)--}\\
 | |
| 534 |   \bl{\texttt{.}} & $\Rightarrow$ & \texttt{putchar(*ptr)}\\
 | |
| 535 |   \bl{\texttt{,}} & $\Rightarrow$ & \texttt{*ptr = getchar()}\\
 | |
| 536 |   \bl{\texttt{[}} & $\Rightarrow$ & \texttt{while(*ptr)\{}\\
 | |
| 537 |   \bl{\texttt{]}} & $\Rightarrow$ & \texttt{\}}\medskip\\
 | |
| 538 | & $\Rightarrow$ & ignore everything else\\ | |
| 539 |   \end{tabular}  
 | |
| 540 |   \end{center}\bigskip  
 | |
| 541 | ||
| 743 | 542 |   \texttt{char field[30000]\\ char *ptr = \&field[15000]}
 | 
| 632 | 543 | |
| 544 | \end{frame}
 | |
| 545 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 546 | ||
| 559 | 547 | |
| 548 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 549 | \begin{frame}[c]
 | |
| 327 
9470cd124667
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
255diff
changeset | 550 | \frametitle{Lectures 1 - 5}
 | 
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 551 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 552 | transforming strings into structured data\\[10mm] | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 553 | |
| 506 | 554 | {\LARGE\bf Lexing} {\hfill{}based on regular expressions}\medskip\\
 | 
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 555 | \hspace{5mm}(recognising ``words'')\\[6mm]
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 556 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 557 | {\LARGE\bf Parsing}\medskip\\
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 558 | \hspace{5mm}(recognising ``sentences'')
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 559 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 560 | \begin{textblock}{1}(10,9.1)
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 561 | \begin{tabular}{c}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 562 | \includegraphics[scale=0.1]{../pics/rosetta.jpg}\\[-2mm]
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 563 | \footnotesize Stone of Rosetta | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 564 | \end{tabular}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 565 | \end{textblock}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 566 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 567 | \end{frame}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 568 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 569 | |
| 636 | 570 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 571 | \begin{frame}[c]
 | |
| 572 |   \frametitle{Lectures 5 - 10}
 | |
| 573 | ||
| 745 | 574 | code generation for a small imperative and a small functional language\\[10mm] | 
| 636 | 575 | |
| 576 |   {\LARGE\bf Interpreters}\medskip\\
 | |
| 577 |   \hspace{5mm}(directly runs a program)\\[6mm]
 | |
| 578 | ||
| 579 |   {\LARGE\bf Compilers}\medskip\\
 | |
| 745 | 580 |   \hspace{5mm}(generate JVM code and LLVM-IR code)
 | 
| 636 | 581 | |
| 745 | 582 |   \begin{textblock}{1}(8.8,8.1)
 | 
| 583 |   \begin{tabular}{c@{}c}
 | |
| 584 |     \includegraphics[scale=0.4]{../pics/javaduke.png} &
 | |
| 585 |     \includegraphics[scale=0.23]{../pics/llvmlogo.png}
 | |
| 636 | 586 |   \end{tabular}
 | 
| 587 |   \end{textblock}
 | |
| 588 | ||
| 589 |   \end{frame}
 | |
| 590 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 591 | ||
| 592 | ||
| 593 | ||
| 1 | 594 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 595 | \begin{frame}[t]
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 596 | \frametitle{Familiar Regular Expr.}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 597 | \small | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 598 | \begin{center}
 | 
| 560 | 599 | \texttt{[a-z0-9\_$\backslash{}$.-]+ @ [a-z0-9$\backslash{}$.-]+ . [a-z$\backslash{}$.]\{2,6\}}
 | 
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 600 | \end{center}\smallskip
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 601 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 602 | \begin{center}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 603 | \begin{tabular}{@{}lp{8.5cm}@{}}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 604 | \pcode{re*} & matches 0 or more times\\
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 605 | \pcode{re+} & matches 1 or more times\\
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 606 | \pcode{re?} & matches 0 or 1 times\\
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 607 | \pcode{re\{n\}}	& matches exactly \pcode{n} number of times\\
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 608 | \pcode{re\{n,m\}} & matches at least \pcode{n} and at most {\tt m} times\\
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 609 | \pcode{[...]} & matches any single character inside the brackets\\
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 610 | \pcode{[^...]} & matches any single character not inside the 
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 611 | brackets\\ | 
| 560 | 612 | \pcode{a-z A-Z} & character ranges\\
 | 
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 613 | \pcode{\\d} & matches digits; equivalent to \pcode{[0-9]}\\
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 614 | \pcode{.} & matches every character except newline\\
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 615 | \pcode{(re)}	& groups regular expressions and remembers 
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 616 | the matched text | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 617 | \end{tabular}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 618 | \end{center}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 619 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 620 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 621 | \end{frame}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 622 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 623 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 624 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 631 | 625 | %\begin{frame}[c]
 | 
| 626 | %\frametitle{Today}
 | |
| 627 | % | |
| 628 | %\begin{itemize}
 | |
| 629 | %\item While the ultimate goal is to implement a small compiler for the JVM | |
| 630 | % \ldots\bigskip | |
| 631 | %\end{itemize}
 | |
| 632 | % | |
| 633 | %Let's start with: | |
| 634 | % | |
| 635 | %\begin{itemize}
 | |
| 636 | %\item a web-crawler | |
| 637 | %\item an email harvester | |
| 559 | 638 | %\item \textcolor{gray}{(a web-scraper)}
 | 
| 631 | 639 | %\end{itemize}
 | 
| 640 | % | |
| 641 | %\end{frame}
 | |
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 642 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 0 | 643 | |
| 2 | 644 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 631 | 645 | %\begin{frame}[t]
 | 
| 646 | %\frametitle{A Web-Crawler}
 | |
| 647 | % | |
| 648 | %\mbox{}\\[10mm]
 | |
| 649 | % | |
| 650 | %\begin{enumerate}
 | |
| 651 | %\item given an URL, read the corresponding webpage | |
| 652 | %\item extract all links from it | |
| 653 | %\item call the web-crawler again for all these links | |
| 654 | %\end{enumerate}
 | |
| 655 | % | |
| 656 | %\end{frame}
 | |
| 2 | 657 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 658 | ||
| 659 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 631 | 660 | %\begin{frame}[t]
 | 
| 661 | %\frametitle{A Web-Crawler}
 | |
| 662 | % | |
| 663 | %\mbox{}\\[10mm]
 | |
| 664 | % | |
| 665 | % | |
| 666 | %\begin{enumerate}
 | |
| 667 | %\item given an URL, read the corresponding webpage | |
| 668 | %\item if not possible print, out a problem | |
| 669 | %\item if possible, extract all links from it | |
| 670 | %\item call the web-crawler again for all these links | |
| 671 | %\end{enumerate}\bigskip\pause
 | |
| 672 | % | |
| 673 | %\small (we need a bound for the number of recursive calls) | |
| 674 | % | |
| 675 | %\small (the purpose is to check all links on my own webpage) | |
| 676 | %\end{frame}
 | |
| 2 | 677 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 678 | ||
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 679 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 680 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 631 | 681 | %\begin{frame}[c]
 | 
| 682 | % | |
| 683 | %\begin{textblock}{1}(2,5)
 | |
| 684 | %\begin{tabular}{c}
 | |
| 685 | %\includegraphics[scale=0.15]{pics/servers.png}\\[-2mm]
 | |
| 686 | %\small Server | |
| 687 | %\end{tabular}
 | |
| 688 | %\end{textblock}
 | |
| 689 | % | |
| 690 | %\begin{textblock}{1}(5.6,4)
 | |
| 691 | %  \begin{tikzpicture}[scale=1.1]
 | |
| 692 | %  \draw[white] (0,1) node (X) {};
 | |
| 693 | %  \draw[white] (2,1) node (Y) {};
 | |
| 694 | %   \draw[white] (0,0) node (X1) {};
 | |
| 695 | %  \draw[white] (2,0) node (Y1) {};
 | |
| 696 | %   \draw[white] (0,-1) node (X2) {};
 | |
| 697 | %  \draw[white] (2,-1) node (Y2) {};
 | |
| 698 | % \draw[red, <-, line width = 2mm] (X) -- (Y); | |
| 699 | %  \node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {};
 | |
| 700 | % \draw[red, ->, line width = 2mm] (X1) -- (Y1); | |
| 701 | %  \node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {};
 | |
| 702 | % \draw[red, <-, line width = 2mm] (X2) -- (Y2); | |
| 703 | %  \node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {};
 | |
| 704 | %  \end{tikzpicture}
 | |
| 705 | %\end{textblock}
 | |
| 706 | % | |
| 707 | % | |
| 708 | %\begin{textblock}{1}(9,5.5)
 | |
| 709 | %\begin{tabular}{c}
 | |
| 710 | %\includegraphics[scale=0.15]{pics/laptop.png}\\[-2mm]
 | |
| 711 | %\small Browser | |
| 712 | %\end{tabular}
 | |
| 713 | %\end{textblock}
 | |
| 714 | %\end{frame}
 | |
| 715 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 716 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 717 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 718 | |
| 0 | 719 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 631 | 720 | %\begin{frame}[c]
 | 
| 721 | %\frametitle{Scala}
 | |
| 722 | % | |
| 723 | %\small A simple Scala function for reading webpages: | |
| 724 | %\bigskip | |
| 725 | % | |
| 726 | %\footnotesize | |
| 727 | %\lstinputlisting{../progs/app0.scala}
 | |
| 728 | %\medskip\pause | |
| 729 | % | |
| 730 | %\lstinline{get_page("""https://nms.kcl.ac.uk/christian.urban/""")}
 | |
| 731 | %\bigskip\medskip\pause | |
| 732 | % | |
| 733 | % | |
| 734 | %\small A slightly more complicated version for handling errors: | |
| 735 | %\smallskip | |
| 736 | % | |
| 737 | %\footnotesize | |
| 738 | %\lstinputlisting[xleftmargin=-4mm]{../progs/app1.scala}
 | |
| 739 | % | |
| 740 | % | |
| 741 | %\end{frame}
 | |
| 0 | 742 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 743 | ||
| 98 
1f3d89fe9820
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
97diff
changeset | 744 | |
| 
1f3d89fe9820
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
97diff
changeset | 745 | |
| 
1f3d89fe9820
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
97diff
changeset | 746 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 3 | 747 | \begin{frame}[t]
 | 
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 748 | \frametitle{A Regular Expression}
 | 
| 3 | 749 | |
| 750 | \begin{itemize}
 | |
| 751 | \item \ldots{} is a pattern or template for specifying strings
 | |
| 752 | \end{itemize}\bigskip
 | |
| 753 | ||
| 754 | \begin{center}  
 | |
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 755 | \only<1>{\scode{"https?://[^"]*"}}%
 | 
| 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 756 | \only<2>{\scode{""""https?://[^"]*"""".r}}
 | 
| 3 | 757 | \end{center}\bigskip\bigskip
 | 
| 758 | ||
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 759 | matches for example\smallskip\\ | 
| 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 760 | \hspace{2mm}\code{"http://www.foobar.com"}\\
 | 
| 559 | 761 | \hspace{2mm}\code{"https://www.tls.org"}\smallskip\\
 | 
| 762 | ||
| 763 | but not\smallskip\\ | |
| 764 | \hspace{2mm}\code{"http://www."foo"bar.com"}\\
 | |
| 3 | 765 | |
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 766 | \end{frame}
 | 
| 3 | 767 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 768 | ||
| 769 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 632 | 770 | %\begin{frame}[c]
 | 
| 771 | %\frametitle{Finding Operations in Scala}
 | |
| 772 | % | |
| 773 | %{\bf\code{rexp.findAllIn(string)}}\medskip
 | |
| 774 | % | |
| 775 | %returns a list of all (sub)strings that match the | |
| 776 | %regular expression | |
| 777 | %\bigskip\bigskip | |
| 778 | % | |
| 779 | % | |
| 780 | %{\bf\code{rexp.findFirstIn(string)}}\medskip
 | |
| 781 | % | |
| 782 | %returns either | |
| 783 | % | |
| 784 | %\begin{itemize}
 | |
| 785 | %\item \code{None} if no (sub)string matches or 
 | |
| 786 | %\item \code{Some(s)} with the first (sub)string
 | |
| 787 | %\end{itemize}
 | |
| 788 | % | |
| 789 | %\end{frame}
 | |
| 0 | 790 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 791 | ||
| 792 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 631 | 793 | %\begin{frame}[c]
 | 
| 794 | % | |
| 795 | %\footnotesize | |
| 796 | %\lstinputlisting{../progs/app2.scala}
 | |
| 797 | % | |
| 798 | %\end{frame}
 | |
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 799 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 0 | 800 | |
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 801 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 631 | 802 | %\begin{frame}[c]
 | 
| 803 | % | |
| 804 | %\small | |
| 805 | %A version that only crawls links in ``my'' domain:\bigskip | |
| 806 | % | |
| 807 | %\footnotesize | |
| 808 | %\lstinputlisting{../progs/app3.scala}
 | |
| 809 | % | |
| 810 | %\end{frame}
 | |
| 0 | 811 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 812 | ||
| 813 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 631 | 814 | %\begin{frame}[c]
 | 
| 815 | %\lstset{xleftmargin=-4mm}
 | |
| 816 | %\small | |
| 817 | %A little email harvester: | |
| 818 | % | |
| 819 | %\footnotesize | |
| 820 | %\lstinputlisting{../progs/app4.scala}\bigskip
 | |
| 821 | % | |
| 822 | %\tiny | |
| 823 | %\url{http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/}
 | |
| 824 | % | |
| 825 | %\end{frame}
 | |
| 3 | 826 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 827 | ||
| 828 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 14 | 829 | \begin{frame}[t]
 | 
| 506 | 830 | \frametitle{Regular Expressions}
 | 
| 0 | 831 | |
| 330 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 832 | Their inductive definition: | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 833 | |
| 14 | 834 | |
| 330 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 835 | \begin{textblock}{6}(2,7.5)
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 836 |   \begin{tabular}{@ {}rrl@ {\hspace{13mm}}l}
 | 
| 512 | 837 |   \bl{$r$} & \bl{$::=$}  & \bl{$\ZERO$}  & nothing\\
 | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 838 |          & \bl{$\mid$} & \bl{$\ONE$}       & empty string / \pcode{""} / $[]$\\
 | 
| 330 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 839 |          & \bl{$\mid$} & \bl{$c$}                         & character\\
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 840 |          & \bl{$\mid$} & \bl{$r_1 + r_2$}  & alternative / choice\\
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 841 |          & \bl{$\mid$} & \bl{$r_1 \cdot r_2$} & sequence\\
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 842 |          & \bl{$\mid$} & \bl{$r^*$}            & star (zero or more)\\
 | 
| 3 | 843 |   \end{tabular}
 | 
| 844 |   \end{textblock}
 | |
| 845 | ||
| 330 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 846 | |
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 847 | \only<2->{\footnotesize
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 848 | \begin{textblock}{9}(2,0.5)
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 849 | \begin{bubble}[9.8cm]
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 850 | \lstinputlisting{../progs/app01.scala}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 851 | \end{bubble}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 852 | \end{textblock}}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 853 | |
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 854 | \end{frame}
 | 
| 3 | 855 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 856 | ||
| 857 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 506 | 858 | %\begin{frame}[t]
 | 
| 859 | %\frametitle{Regular Expressions}
 | |
| 860 | % | |
| 861 | %\small | |
| 862 | %In Scala:\bigskip | |
| 863 | % | |
| 864 | %\footnotesize | |
| 865 | %\lstinputlisting{../progs/app51.scala}
 | |
| 866 | % | |
| 867 | % | |
| 868 | %\end{frame}
 | |
| 0 | 869 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 870 | ||
| 871 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 872 | \begin{frame}[t]
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 873 | \frametitle{Strings}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 874 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 875 | \ldots are lists of characters. For example \code{"hello"}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 876 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 877 | \begin{center}
 | 
| 330 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 878 | \bl{$[h, e, l, l, o]$} or just \bl{$hello$}
 | 
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 879 | \end{center}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 880 | |
| 330 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 881 | the empty string: \bl{$[]$} or \bl{\pcode{""}}\bigskip\\
 | 
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 882 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 883 | the concatenation of two strings: | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 884 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 885 | \begin{center}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 886 | \bl{$s_1 \,@\, s_2$}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 887 | \end{center}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 888 | |
| 631 | 889 | \bl{\textit{foo $@$ bar = foobar}}\\
 | 
| 890 | \bl{\textit{baz $@\, []$ = baz}}
 | |
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 891 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 892 | \end{frame}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 893 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 894 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 895 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 330 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 896 | \begin{frame}[c]
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 897 | \frametitle{Languages, Strings}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 898 | |
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 899 | \begin{itemize}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 900 | \item \alert{\bf Strings} are lists of characters, for example
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 901 | \begin{center}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 902 | \bl{$[]$},\;\bl{$abc$}  \hspace{2cm}(Pattern match: \bl{$c\!::\!s$})
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 903 | \end{center}\bigskip
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 904 | |
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 905 | |
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 906 | \item A \alert{\bf language} is a set of strings, for example\medskip
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 907 | \begin{center}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 908 | \bl{$\{[], hello, \textit{foobar}, a, abc\}$}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 909 | \end{center}\bigskip
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 910 | |
| 332 
4755ad4b457b
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 911 | \item \alert{\bf Concatenation} of strings and languages
 | 
| 330 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 912 | |
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 913 | \begin{center}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 914 | \begin{tabular}{rcl}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 915 | \bl{$\textit{foo}\;@\;bar$} & \bl{$=$} & \bl{$\textit{foobar}$}\medskip\\
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 916 | \bl{$A\;@\;B$} & \bl{$\dn$} & \bl{$\{ s_1\,@\,s_2 \;\mid\; s_1 \in A \wedge s_2 \in B\}$}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 917 | \end{tabular}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 918 | \end{center}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 919 | |
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 920 | %\item The \alert{\bf meaning} of a regular expression is a set of 
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 921 | % strings, or language. | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 922 | \end{itemize}  
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 923 | |
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 924 | \end{frame}
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 925 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 926 | |
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 927 | |
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 928 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 0 | 929 | \begin{frame}[c]
 | 
| 745 | 930 | \frametitle{The Meaning of a Regex}
 | 
| 0 | 931 | |
| 4 | 932 | \begin{textblock}{15}(1,4)
 | 
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 933 |  \begin{tabular}{rcl}
 | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 934 |  \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
 | 
| 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 935 |  \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 936 |  \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
 | 
| 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 937 |  \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
 | 
| 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 938 |  \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) \}$}\\
 | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 939 |  \bl{$L(r^*)$}           & \bl{$\dn$} & \onslide<4->{\bl{$\bigcup_{0 \le n} L(r)^n$}}\\
 | 
| 4 | 940 |   \end{tabular}\bigskip
 | 
| 3 | 941 | |
| 4 | 942 | \onslide<2->{
 | 
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 943 | \hspace{5mm}\bl{$L(r)^0 \;\dn\; \{[]\}$}\\
 | 
| 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 944 | \bl{$L(r)^{n+1} \;\dn\; L(r) \,@\, L(r)^n$}\hspace{9mm}\onslide<3->{\small\textcolor{gray}{(append on sets)}\\
 | 
| 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 945 | \small\hspace{5cm}\textcolor{gray}{$\{ s_1 @ s_2 \;|\; s_1\in L(r) \wedge s_2 \in L(r)^n \}$}}
 | 
| 4 | 946 | } | 
| 947 |     \end{textblock}
 | |
| 948 | ||
| 745 | 949 | \end{frame}
 | 
| 0 | 950 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 951 | ||
| 5 | 952 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 953 | \begin{frame}[c]
 | |
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 954 | \frametitle{The Meaning of Matching}
 | 
| 5 | 955 | |
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 956 | \begin{bubble}[10cm]
 | 
| 559 | 957 | \large\bf | 
| 507 | 958 | A regular expression \bl{$r$} matches a string~\bl{$s$} 
 | 
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 959 | provided | 
| 5 | 960 | |
| 961 | \begin{center}
 | |
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 962 | \bl{$s \in L(r)$}\\ 
 | 
| 5 | 963 | \end{center}
 | 
| 330 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 964 | \end{bubble}\bigskip\bigskip
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 965 | |
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 966 | \ldots and the point of the next lecture is | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 967 | to decide this problem as fast as possible (unlike Python, | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 968 | Ruby, Java) | 
| 5 | 969 | |
| 254 
dcd4688690ce
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
253diff
changeset | 970 | \end{frame}
 | 
| 5 | 971 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 972 | ||
| 631 | 973 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 974 | \begin{frame}[c]
 | |
| 975 |   \frametitle{The Power Operation}
 | |
| 976 | ||
| 977 |   \begin{itemize}
 | |
| 978 |   \item The \alert{\textbf{\boldmath$n$th Power}} of a language:
 | |
| 979 | ||
| 980 |   \begin{center}
 | |
| 981 |   \begin{tabular}{lcl}
 | |
| 982 |   \bl{$A^0$}    & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | |
| 983 |   \bl{$A^{n+1}$} & \bl{$\dn$} & \bl{$A \,@\, A^n$}
 | |
| 984 |   \end{tabular}
 | |
| 985 |   \end{center}\bigskip
 | |
| 986 | ||
| 987 | \item[] For example | |
| 988 | ||
| 989 |   \begin{center}
 | |
| 990 |   \begin{tabular}{lcl@{\hspace{10mm}}l}
 | |
| 991 |   \bl{$A^4$} & \bl{$=$} & \bl{$A \,@\, A \,@\, A \,@\, A$} & \bl{$(@\,\{[]\})$}\\
 | |
| 992 |   \bl{$A^1$} & \bl{$=$} & \bl{$A$} & \bl{$(@\,\{[]\})$}\\
 | |
| 993 |   \bl{$A^0$} & \bl{$=$} & \bl{$\{[]\}$}\\
 | |
| 994 |   \end{tabular}
 | |
| 995 |   \end{center}
 | |
| 996 | ||
| 997 |   \end{itemize}  
 | |
| 998 | ||
| 999 |   \end{frame}
 | |
| 1000 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1001 | ||
| 1002 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1003 | \begin{frame}[c]
 | |
| 1004 |   \frametitle{Questions}
 | |
| 1005 | ||
| 1006 |   \begin{itemize}
 | |
| 1007 |   \item Say \bl{$A = \{[a],[b],[c],[d]\}$}.\bigskip
 | |
| 1008 | ||
| 1009 | \item[] | |
| 1010 |   How many strings are in \bl{$A^4$}\,?
 | |
| 1011 | \bigskip\medskip\pause | |
| 1012 | ||
| 1013 | ||
| 1014 | \item[] | |
| 1015 |   What if \bl{$A = \{[a],[b],[c],[]\}$};\\ 
 | |
| 1016 |   how many strings are then in \bl{$A^4$}\,?
 | |
| 1017 |   \end{itemize}  
 | |
| 1018 | ||
| 1019 | \end{frame}
 | |
| 1020 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1021 | ||
| 1022 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1023 | \begin{frame}[c]
 | |
| 743 | 1024 | \frametitle{Languages (Sets of Strings)}
 | 
| 1025 | ||
| 1026 | \begin{itemize}
 | |
| 1027 | ||
| 1028 | \item A \alert{\bf Language} is a set of strings, for example\medskip
 | |
| 1029 | \begin{center}
 | |
| 1030 | \bl{$\{[], hello, foobar, a, abc\}$}
 | |
| 1031 | \end{center}\bigskip
 | |
| 1032 | ||
| 1033 | \item \alert{\bf Concatenation} for strings and languages
 | |
| 1034 | ||
| 1035 | \begin{center}
 | |
| 1036 | \begin{tabular}{rcl}
 | |
| 1037 | \bl{$foo\;@\;bar$} & \bl{$=$} & \bl{$foobar$}\medskip\\
 | |
| 1038 | \bl{$A\;@\;B$}     & \bl{$\dn$} & \bl{$\{ s_1\,@\,s_2 \;\mid\; s_1 \in A \wedge s_2 \in B\}$}
 | |
| 1039 | \end{tabular}
 | |
| 1040 | \end{center}
 | |
| 1041 | \bigskip | |
| 1042 | ||
| 1043 | \small | |
| 1044 | \item [] For example \bl{$A = \{foo, bar\}$}, \bl{$B = \{a, b\}$}
 | |
| 1045 | ||
| 1046 | \[ | |
| 1047 | \bl{A \,@\, B = \{fooa, foob, bara, barb\}}
 | |
| 1048 | \] | |
| 1049 | ||
| 1050 | \end{itemize}  
 | |
| 1051 | \end{frame}
 | |
| 1052 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1053 | ||
| 1054 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1055 | \begin{frame}[c]
 | |
| 1056 |   \frametitle{Two Corner Cases}
 | |
| 1057 | ||
| 1058 | \Large | |
| 1059 |   \begin{center}
 | |
| 1060 |   \bl{$A \,@\, \{[]\} = \;?$}\bigskip\bigskip\pause\\
 | |
| 1061 |   \bl{$A \,@\, \{\} = \;?$}
 | |
| 1062 |   \end{center}  
 | |
| 1063 | ||
| 1064 |   \end{frame}
 | |
| 1065 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1066 | ||
| 1067 | ||
| 1068 | ||
| 1069 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1070 | \begin{frame}[c]
 | |
| 745 | 1071 | \frametitle{The Meaning of a Regex}
 | 
| 743 | 1072 | |
| 1073 | ...all the strings a regular expression can match. | |
| 1074 | ||
| 1075 | \begin{center}
 | |
| 1076 |  \begin{tabular}{rcl}
 | |
| 1077 |  \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
 | |
| 1078 |  \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | |
| 1079 |  \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
 | |
| 1080 |  \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
 | |
| 1081 |  \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \,@\, L(r_2)$}\\
 | |
| 1082 |  \bl{$L(r^*)$}           & \bl{$\dn$} & \\
 | |
| 1083 |   \end{tabular}
 | |
| 1084 | \end{center}
 | |
| 1085 | ||
| 1086 | \begin{textblock}{14}(1.5,13.5)\small
 | |
| 1087 | \bl{$L$} is a function from regular expressions to 
 | |
| 1088 | sets of strings (languages):\smallskip\\ | |
| 1089 | \bl{\quad$L$ : Rexp $\Rightarrow$ Set$[$String$]$}
 | |
| 1090 | \end{textblock}
 | |
| 1091 | ||
| 1092 | \end{frame}
 | |
| 1093 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1094 | ||
| 1095 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1096 | \begin{frame}[c]
 | |
| 1097 | \frametitle{The Power Operation}
 | |
| 1098 | ||
| 1099 | \begin{itemize}
 | |
| 1100 | \item The \alert{\textbf{\boldmath$n$th Power}} of a language:
 | |
| 1101 | ||
| 1102 | \begin{center}
 | |
| 1103 | \begin{tabular}{lcl}
 | |
| 1104 | \bl{$A^0$}    & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | |
| 1105 | \bl{$A^{n+1}$} & \bl{$\dn$} & \bl{$A \,@\, A^n$}
 | |
| 1106 | \end{tabular}
 | |
| 1107 | \end{center}\bigskip
 | |
| 1108 | ||
| 1109 | \item[] For example | |
| 1110 | ||
| 1111 | \begin{center}
 | |
| 1112 | \begin{tabular}{lcl@{\hspace{10mm}}l}
 | |
| 1113 | \bl{$A^4$} & \bl{$=$} & \bl{$A \,@\, A \,@\, A \,@\, A$} & \bl{$(@\,\{[]\})$}\\
 | |
| 1114 | \bl{$A^1$} & \bl{$=$} & \bl{$A$} & \bl{$(@\,\{[]\})$}\\
 | |
| 1115 | \bl{$A^0$} & \bl{$=$} & \bl{$\{[]\}$}\\
 | |
| 1116 | \end{tabular}
 | |
| 1117 | \end{center}
 | |
| 1118 | ||
| 1119 | \end{itemize}  
 | |
| 1120 | ||
| 1121 | \end{frame}
 | |
| 1122 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1123 | ||
| 1124 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1125 | \begin{frame}[c]
 | |
| 631 | 1126 |   \frametitle{The Star Operation}
 | 
| 1127 | ||
| 1128 |   \begin{itemize}
 | |
| 1129 |   \item The \alert{\bf Kleene Star} of a \underline{language}:
 | |
| 1130 | \bigskip | |
| 1131 | ||
| 1132 |   \begin{center}
 | |
| 1133 |   \begin{tabular}{c}
 | |
| 1134 |   \bl{$A\star \dn \bigcup_{0\le n} A^n$}
 | |
| 1135 |   \end{tabular}
 | |
| 1136 |   \end{center}\bigskip
 | |
| 1137 | ||
| 1138 | \item[] This expands to | |
| 1139 | ||
| 1140 | \[ | |
| 1141 |   \bl{A^0 \cup A^1 \cup A^2 \cup A^3 \cup A^4 \cup \ldots}
 | |
| 1142 | \] | |
| 1143 | ||
| 1144 | or | |
| 1145 | ||
| 1146 | \small | |
| 1147 | \[ | |
| 1148 |   \bl{\{[]\} \;\cup\; A \;\cup\; A\,@\,A \;\cup\; 
 | |
| 1149 | A\,@\,A\,@\,A \;\cup\; A\,@\,A\,@\,A\,@\,A \cup \ldots} | |
| 1150 | \] | |
| 1151 | ||
| 1152 |   \end{itemize}  
 | |
| 1153 | ||
| 1154 |   \end{frame}
 | |
| 1155 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1156 | ||
| 1157 | ||
| 0 | 1158 | |
| 1159 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1160 | \begin{frame}[c]
 | |
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1161 | \frametitle{Written Exam}
 | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1162 | |
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1163 | \begin{itemize}
 | 
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 1164 | \item Accounts for 80\%.\bigskip | 
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1165 | |
| 559 | 1166 | \item The question ``\textit{Is this relevant for
 | 
| 330 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 1167 | the exam?}'' is very demotivating for the lecturer!\bigskip\\ | 
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1168 | |
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1169 | \item Deal: Whatever is in the homework (and is not marked | 
| 330 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 1170 |       ``\textit{optional}'') is relevant for the exam.\bigskip
 | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 1171 | |
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 1172 | \item Each lecture has also a handout. There are also handouts about | 
| 
0806e45d873c
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
328diff
changeset | 1173 | notation and Scala. | 
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1174 | \end{itemize}
 | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1175 | |
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1176 | \end{frame}
 | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1177 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1178 | |
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1179 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1180 | \begin{frame}[t]
 | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1181 | \frametitle{Coursework}
 | 
| 0 | 1182 | |
| 1183 | \begin{itemize}
 | |
| 428 
a47c4227a0c6
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
334diff
changeset | 1184 | \item Accounts for 20\%. Two strands. Choose \alert{\bf one}!\bigskip
 | 
| 0 | 1185 | \end{itemize}
 | 
| 1186 | ||
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 1187 | \begin{columns}[t]
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 1188 | \begin{column}{.5\textwidth}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 1189 | \underline{\bf Strand 1}\medskip
 | 
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1190 | \begin{itemize}
 | 
| 631 | 1191 | \item 4 programming tasks: | 
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1192 | \begin{itemize}
 | 
| 631 | 1193 | \item matcher (4\%, 11.10.) | 
| 1194 | \item lexer (5\%, 04.11.) | |
| 1195 | \item parser (5\%, 22.11.) | |
| 1196 | \item compiler (6\%, 13.12.) | |
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1197 | \end{itemize}
 | 
| 631 | 1198 | \item in any lang.~you like,\\ but I want to see the\\ code | 
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1199 | \end{itemize}
 | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1200 | \end{column}
 | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1201 | |
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1202 | \hspace{-45pt}\vrule{}\hspace{10pt}
 | 
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 1203 | \begin{column}{.5\textwidth}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 1204 | \underline{\bf Strand 2}\smallskip\begin{itemize}
 | 
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1205 | \item one task: prove the correctness of a regular expression matcher in | 
| 559 | 1206 | the \underline{Isabelle} theorem prover
 | 
| 631 | 1207 | \item 20\%, submission on~13.12.\hspace{-5mm}\mbox{}
 | 
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1208 | \end{itemize}
 | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1209 | \end{column}
 | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1210 | \end{columns}\medskip
 | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1211 | |
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1212 | \small | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1213 | \begin{itemize}
 | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1214 | \item Solving more than one strand will {\bf not} give you more 
 | 
| 506 | 1215 | marks. | 
| 1216 | ||
| 253 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1217 | \end{itemize}
 | 
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1218 | |
| 
75c469893514
added coursework
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
252diff
changeset | 1219 | \end{frame}
 | 
| 0 | 1220 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 1221 | ||
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 1222 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 745 | 1223 | %\begin{frame}[c]
 | 
| 1224 | %\frametitle{Lecture Capture}
 | |
| 1225 | % | |
| 1226 | %\begin{itemize}
 | |
| 1227 | %\item Hope it works\ldots\pause actually no, it does not!\medskip\pause | |
| 1228 | %\item It is important to use lecture capture wisely\\ (it is only the ``baseline''): | |
| 1229 | %\begin{itemize}  
 | |
| 1230 | %\item Lecture recordings are a study and revision aid. | |
| 1231 | %\item Statistically, there is a clear and direct link between attendance and | |
| 1232 | % attainment: students who do not attend lectures, do less well in exams. | |
| 1233 | %\end{itemize}
 | |
| 1234 | % | |
| 1235 | %\item Attending a lecture is more than watching it online -- if you do not | |
| 1236 | %attend, you miss out! | |
| 1237 | % | |
| 1238 | %\end{itemize}
 | |
| 1239 | % | |
| 1240 | %\end{frame}
 | |
| 506 | 1241 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 1242 | ||
| 1243 | ||
| 1244 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1245 | \begin{frame}[c]
 | |
| 255 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 1246 | \frametitle{\begin{tabular}{c}\\[3cm]\alert{Questions?}\end{tabular}}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 1247 | |
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 1248 | \mbox{}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 1249 | \end{frame}
 | 
| 
96a99237fa42
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
254diff
changeset | 1250 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
| 0 | 1251 | \end{document}
 | 
| 1252 | ||
| 1253 | %%% Local Variables: | |
| 1254 | %%% mode: latex | |
| 1255 | %%% TeX-master: t | |
| 1256 | %%% End: | |
| 1257 |