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