author | Christian Urban <christian.urban@kcl.ac.uk> |
Mon, 17 Aug 2020 17:42:37 +0100 | |
changeset 744 | 99c5916d9a8f |
parent 743 | 6acabeecdf75 |
child 745 | 7dc3643a0cc5 |
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:
215
diff
changeset
|
3 |
\usepackage{../slides} |
e8ef8f38ca84
added style files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
4 |
\usepackage{../graphics} |
215
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
98
diff
changeset
|
5 |
\usepackage{../langs} |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
98
diff
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:
215
diff
changeset
|
10 |
\hfuzz=220pt |
e8ef8f38ca84
added style files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
11 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
12 |
\lstset{language=Scala, |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
13 |
style=mystyle, |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
14 |
numbersep=0pt, |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
15 |
numbers=none, |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
16 |
xleftmargin=0mm} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
17 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
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:
334
diff
changeset
|
21 |
\renewcommand{\slidecaption}{CFL 01, King's College London} |
0 | 22 |
|
721
e3c64f22dd31
added slides from Rochester
Christian Urban <christian.urban@kcl.ac.uk>
parents:
637
diff
changeset
|
23 |
%% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect1/main.pdf |
e3c64f22dd31
added slides from Rochester
Christian Urban <christian.urban@kcl.ac.uk>
parents:
637
diff
changeset
|
24 |
%% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect2/main.pdf |
e3c64f22dd31
added slides from Rochester
Christian Urban <christian.urban@kcl.ac.uk>
parents:
637
diff
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:
252
diff
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:
334
diff
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:
252
diff
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:
254
diff
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:
254
diff
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:
252
diff
changeset
|
254 |
\end{frame} |
0 | 255 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1 | 256 |
|
631 | 257 |
|
258 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
259 |
\begin{frame}[c] |
|
744 | 260 |
\frametitle{Why Bother with Compilers?} |
631 | 261 |
|
744 | 262 |
\textbf{Boeings 777}: First flight in 1994. They want to achieve |
263 |
triple redundancy in hardware faults.\bigskip |
|
631 | 264 |
|
265 |
They compile 1 Ada program to\medskip |
|
266 |
||
267 |
\begin{itemize} |
|
268 |
\item Intel 80486 |
|
269 |
\item Motorola 68040 (old Macintosh's) |
|
270 |
\item AMD 29050 (RISC chips used often in laser printers) |
|
271 |
\end{itemize}\medskip\medskip |
|
272 |
||
273 |
using 3 independent compilers.\bigskip\pause |
|
274 |
||
275 |
\small Airbus uses C and static analysers. Recently started using CompCert. |
|
276 |
||
277 |
\end{frame} |
|
278 |
%%%%%%%%%%% |
|
279 |
||
280 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
281 |
\begin{frame}[c] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
282 |
\frametitle{Why Bother?} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
283 |
|
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
284 |
\begin{columns}[t] |
744 | 285 |
\begin{column}{.4\textwidth} |
559 | 286 |
Ruby, Python, Java 8\medskip\\ |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
287 |
\begin{tikzpicture}\footnotesize |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
288 |
\begin{axis}[ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
289 |
xlabel={$n$}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
290 |
x label style={at={(1.05,0.0)}}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
291 |
ylabel={time in secs}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
292 |
enlargelimits=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
293 |
xtick={0,5,...,30}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
294 |
xmax=33, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
295 |
ymax=35, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
296 |
ytick={0,5,...,30}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
297 |
scaled ticks=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
298 |
axis lines=left, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
299 |
width=5.5cm, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
300 |
height=4cm, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
301 |
legend entries={Python,Ruby}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
302 |
legend pos=north west, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
303 |
legend cell align=left] |
559 | 304 |
\addplot[blue,mark=*, mark options={fill=white}] table {re-python.data}; |
305 |
\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:
334
diff
changeset
|
306 |
\end{axis} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
307 |
\end{tikzpicture} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
308 |
\begin{tikzpicture}\footnotesize |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
309 |
\begin{axis}[ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
310 |
xlabel={$n$}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
311 |
x label style={at={(1.05,0.0)}}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
312 |
ylabel={time in secs}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
313 |
enlargelimits=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
314 |
xtick={0,5,...,30}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
315 |
xmax=33, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
316 |
ymax=35, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
317 |
ytick={0,5,...,30}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
318 |
scaled ticks=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
319 |
axis lines=left, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
320 |
width=5.5cm, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
321 |
height=4cm, |
631 | 322 |
legend entries={Python, Java 8, JavaScript}, |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
323 |
legend pos=north west, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
324 |
legend cell align=left] |
559 | 325 |
\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:
334
diff
changeset
|
326 |
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data}; |
631 | 327 |
\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:
334
diff
changeset
|
328 |
\end{axis} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
329 |
\end{tikzpicture} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
330 |
|
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
331 |
\end{column} |
744 | 332 |
\begin{column}{.4\textwidth} |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
333 |
Us (after next lecture)\medskip\\ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
334 |
\begin{tikzpicture}\footnotesize |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
335 |
\begin{axis}[ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
336 |
xlabel={$n$}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
337 |
x label style={at={(1.07,0.0)}}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
338 |
ylabel={time in secs}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
339 |
enlargelimits=false, |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
437
diff
changeset
|
340 |
xtick={0,5000,...,10000}, |
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
437
diff
changeset
|
341 |
xmax=11000, |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
342 |
ymax=35, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
343 |
ytick={0,5,...,30}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
344 |
scaled ticks=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
345 |
axis lines=left, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
346 |
width=5.5cm, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
347 |
height=4cm] |
437
fe387fcbf2ee
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
428
diff
changeset
|
348 |
\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:
334
diff
changeset
|
349 |
\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:
334
diff
changeset
|
350 |
\end{axis} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
351 |
\end{tikzpicture} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
352 |
\begin{tikzpicture}\footnotesize |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
353 |
\begin{axis}[ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
354 |
xlabel={$n$}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
355 |
x label style={at={(1.07,0.0)}}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
356 |
ylabel={time in secs}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
357 |
enlargelimits=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
358 |
ymax=35, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
359 |
ytick={0,5,...,30}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
360 |
scaled ticks=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
361 |
axis lines=left, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
362 |
width=5.5cm, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
363 |
height=4cm] |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
364 |
\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:
334
diff
changeset
|
365 |
\end{axis} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
366 |
\end{tikzpicture} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
367 |
\end{column} |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
368 |
\end{columns}\bigskip |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
369 |
|
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
370 |
\small\centering |
635 | 371 |
matching \bl{\texttt{[a?]\{n\}[a]\{n\}}} and \bl{\texttt{(a*)*b}} |
372 |
against \bl{$\underbrace{\texttt{a}...\texttt{a}}_n$} |
|
510 | 373 |
\end{frame} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
374 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
631 | 375 |
|
376 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
377 |
\begin{frame}[c,fragile] |
|
378 |
\frametitle{Incidents} |
|
379 |
||
380 |
\begin{itemize} |
|
381 |
\item a global outage on 2 July 2019 at \textbf{Cloudflare} |
|
382 |
(first one for six years)\medskip |
|
383 |
||
384 |
\begin{center}\small\color{blue} |
|
385 |
\begin{verbatim} |
|
386 |
(?:(?:\"|'|\]|\}|\\|\d|(?:nan|infinity|true|false| |
|
387 |
null|undefined|symbol|math)|\`|\-|\+)+[)]*;?((?:\s |
|
388 |
|-|~|!|{}|\|\||\+)*.*(?:.*=.*))) |
|
389 |
\end{verbatim} |
|
390 |
\end{center}\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip |
|
391 |
||
392 |
\item on 20 July 2016 the \textbf{Stack Exchange} webpage went down |
|
393 |
because of an evil regular expression |
|
394 |
\end{itemize} |
|
395 |
||
396 |
\begin{textblock}{6}(9,7.6) |
|
728 | 397 |
\includegraphics[scale=0.14]{../pics/cloudflare.png}\\ |
631 | 398 |
\footnotesize |
399 |
It serves more web traffic than Twitter, Amazon, Apple, Instagram, Bing \& Wikipedia combined. |
|
400 |
\end{textblock} |
|
401 |
||
402 |
\end{frame} |
|
403 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
404 |
||
560 | 405 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
406 |
\begin{frame}[c] |
|
407 |
\frametitle{Evil Regular Expressions} |
|
408 |
||
409 |
\begin{itemize} |
|
410 |
\item \alert{R}egular \alert{e}xpression \alert{D}enial \alert{o}f \alert{S}ervice (ReDoS)\medskip |
|
411 |
\item Evil regular expressions\medskip |
|
412 |
\begin{itemize} |
|
413 |
\item \bl{$(a^{?\{n\}}) \cdot a^{\{n\}}$} |
|
414 |
\item \bl{$(a^*)^*\cdot b$} |
|
630 | 415 |
\item \bl{$([a-z]^+)^*$} |
560 | 416 |
\item \bl{$(a + a \cdot a)^*$} |
417 |
\item \bl{$(a + a^?)^*$} |
|
418 |
\end{itemize} |
|
419 |
||
420 |
\item sometimes also called \alert{catastrophic backtracking} |
|
421 |
\item this is a problem for \alert{N}etwork \alert{I}ntrusion |
|
631 | 422 |
\alert{D}etection systems, Cloudflare, StackExchange, Atom editor |
560 | 423 |
\item \url{https://vimeo.com/112065252} |
424 |
\end{itemize} |
|
425 |
||
426 |
\end{frame} |
|
427 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
428 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
429 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
430 |
\begin{frame}[c] |
559 | 431 |
\frametitle{The Acad.~Subject is Mature} |
432 |
||
631 | 433 |
\bigskip |
559 | 434 |
\begin{itemize} |
631 | 435 |
\item Turing Machines, 1936 (a tape as memory) |
559 | 436 |
\item Regular Expressions, 1956\\ |
631 | 437 |
\item The first compiler for COBOL, 1957\\ (Grace Hopper)\medskip |
559 | 438 |
\item But surprisingly research papers are still published nowadays\\ |
439 |
\item ``Parsing: The Solved Problem That Isn't'' |
|
440 |
\end{itemize} |
|
441 |
||
442 |
\begin{flushright} |
|
443 |
\includegraphics[scale=0.3]{pics/hopper.jpg}\\ |
|
444 |
\footnotesize\textcolor{gray}{Grace Hopper} |
|
445 |
\end{flushright} |
|
446 |
||
447 |
||
448 |
\begin{flushright} |
|
449 |
\mbox{}\\[-6mm] |
|
450 |
{\footnotesize\textcolor{gray}{(she made it to David Letterman's Tonight Show,\\[-2mm] |
|
722 | 451 |
\url{https://youtu.be/3N_ywhx6_K0?t=31})}} |
559 | 452 |
\end{flushright} |
453 |
||
454 |
\end{frame} |
|
455 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
456 |
||
632 | 457 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
458 |
\begin{frame}[c] |
|
636 | 459 |
\frametitle{Remember BF*** from PEP?} |
559 | 460 |
|
632 | 461 |
\begin{center} |
462 |
\begin{tabular}{lcl} |
|
463 |
\bl{\texttt{>}} & $\Rightarrow$ & move one cell right\\ |
|
464 |
\bl{\texttt{<}} & $\Rightarrow$ & move one cell left\\ |
|
465 |
\bl{\texttt{+}} & $\Rightarrow$ & increase cell by one\\ |
|
466 |
\bl{\texttt{-}} & $\Rightarrow$ & decrease cell by one\\ |
|
467 |
\bl{\texttt{.}} & $\Rightarrow$ & print current cell\\ |
|
468 |
\bl{\texttt{,}} & $\Rightarrow$ & input current cell\\ |
|
469 |
\bl{\texttt{[}} & $\Rightarrow$ & loop begin\\ |
|
470 |
\bl{\texttt{]}} & $\Rightarrow$ & loop end\medskip\\ |
|
471 |
& $\Rightarrow$ & everything else is a comment\\ |
|
472 |
\end{tabular} |
|
473 |
\end{center} |
|
474 |
||
475 |
\end{frame} |
|
476 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
477 |
||
478 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
479 |
\begin{frame}[c] |
|
636 | 480 |
\frametitle{A ``Compiler'' for BF***} |
632 | 481 |
|
482 |
\begin{center} |
|
483 |
\begin{tabular}{lcl} |
|
484 |
\bl{\texttt{>}} & $\Rightarrow$ & \texttt{ptr++}\\ |
|
485 |
\bl{\texttt{<}} & $\Rightarrow$ & \texttt{ptr--}\\ |
|
486 |
\bl{\texttt{+}} & $\Rightarrow$ & \texttt{(*ptr)++}\\ |
|
487 |
\bl{\texttt{-}} & $\Rightarrow$ & \texttt{(*ptr)--}\\ |
|
488 |
\bl{\texttt{.}} & $\Rightarrow$ & \texttt{putchar(*ptr)}\\ |
|
489 |
\bl{\texttt{,}} & $\Rightarrow$ & \texttt{*ptr = getchar()}\\ |
|
490 |
\bl{\texttt{[}} & $\Rightarrow$ & \texttt{while(*ptr)\{}\\ |
|
491 |
\bl{\texttt{]}} & $\Rightarrow$ & \texttt{\}}\medskip\\ |
|
492 |
& $\Rightarrow$ & ignore everything else\\ |
|
493 |
\end{tabular} |
|
494 |
\end{center}\bigskip |
|
495 |
||
743 | 496 |
\texttt{char field[30000]\\ char *ptr = \&field[15000]} |
632 | 497 |
|
498 |
\end{frame} |
|
499 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
500 |
||
559 | 501 |
|
502 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
503 |
\begin{frame}[c] |
|
327
9470cd124667
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
255
diff
changeset
|
504 |
\frametitle{Lectures 1 - 5} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
505 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
506 |
transforming strings into structured data\\[10mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
507 |
|
506 | 508 |
{\LARGE\bf Lexing} {\hfill{}based on regular expressions}\medskip\\ |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
509 |
\hspace{5mm}(recognising ``words'')\\[6mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
510 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
511 |
{\LARGE\bf Parsing}\medskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
512 |
\hspace{5mm}(recognising ``sentences'') |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
513 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
514 |
\begin{textblock}{1}(10,9.1) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
515 |
\begin{tabular}{c} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
516 |
\includegraphics[scale=0.1]{../pics/rosetta.jpg}\\[-2mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
517 |
\footnotesize Stone of Rosetta |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
518 |
\end{tabular} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
519 |
\end{textblock} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
520 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
521 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
522 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
523 |
|
636 | 524 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
525 |
\begin{frame}[c] |
|
526 |
\frametitle{Lectures 5 - 10} |
|
527 |
||
528 |
code generation for a small imperative and a small functional languages\\[10mm] |
|
529 |
||
530 |
{\LARGE\bf Interpreters}\medskip\\ |
|
531 |
\hspace{5mm}(directly runs a program)\\[6mm] |
|
532 |
||
533 |
{\LARGE\bf Compilers}\medskip\\ |
|
534 |
\hspace{5mm}(generates JVM code) |
|
535 |
||
536 |
\begin{textblock}{1}(10,8.1) |
|
537 |
\begin{tabular}{c} |
|
538 |
\includegraphics[scale=0.4]{../pics/javaduke.png} |
|
539 |
\end{tabular} |
|
540 |
\end{textblock} |
|
541 |
||
542 |
\end{frame} |
|
543 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
544 |
||
545 |
||
546 |
||
1 | 547 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
548 |
\begin{frame}[t] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
549 |
\frametitle{Familiar Regular Expr.} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
550 |
\small |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
551 |
\begin{center} |
560 | 552 |
\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:
254
diff
changeset
|
553 |
\end{center}\smallskip |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
554 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
555 |
\begin{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
556 |
\begin{tabular}{@{}lp{8.5cm}@{}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
557 |
\pcode{re*} & matches 0 or more times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
558 |
\pcode{re+} & matches 1 or more times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
559 |
\pcode{re?} & matches 0 or 1 times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
560 |
\pcode{re\{n\}} & matches exactly \pcode{n} number of times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
561 |
\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:
254
diff
changeset
|
562 |
\pcode{[...]} & matches any single character inside the brackets\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
563 |
\pcode{[^...]} & matches any single character not inside the |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
564 |
brackets\\ |
560 | 565 |
\pcode{a-z A-Z} & character ranges\\ |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
566 |
\pcode{\\d} & matches digits; equivalent to \pcode{[0-9]}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
567 |
\pcode{.} & matches every character except newline\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
568 |
\pcode{(re)} & groups regular expressions and remembers |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
569 |
the matched text |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
570 |
\end{tabular} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
571 |
\end{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
572 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
573 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
574 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
575 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
576 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
577 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
631 | 578 |
%\begin{frame}[c] |
579 |
%\frametitle{Today} |
|
580 |
% |
|
581 |
%\begin{itemize} |
|
582 |
%\item While the ultimate goal is to implement a small compiler for the JVM |
|
583 |
% \ldots\bigskip |
|
584 |
%\end{itemize} |
|
585 |
% |
|
586 |
%Let's start with: |
|
587 |
% |
|
588 |
%\begin{itemize} |
|
589 |
%\item a web-crawler |
|
590 |
%\item an email harvester |
|
559 | 591 |
%\item \textcolor{gray}{(a web-scraper)} |
631 | 592 |
%\end{itemize} |
593 |
% |
|
594 |
%\end{frame} |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
595 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 596 |
|
2 | 597 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
631 | 598 |
%\begin{frame}[t] |
599 |
%\frametitle{A Web-Crawler} |
|
600 |
% |
|
601 |
%\mbox{}\\[10mm] |
|
602 |
% |
|
603 |
%\begin{enumerate} |
|
604 |
%\item given an URL, read the corresponding webpage |
|
605 |
%\item extract all links from it |
|
606 |
%\item call the web-crawler again for all these links |
|
607 |
%\end{enumerate} |
|
608 |
% |
|
609 |
%\end{frame} |
|
2 | 610 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
611 |
||
612 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
631 | 613 |
%\begin{frame}[t] |
614 |
%\frametitle{A Web-Crawler} |
|
615 |
% |
|
616 |
%\mbox{}\\[10mm] |
|
617 |
% |
|
618 |
% |
|
619 |
%\begin{enumerate} |
|
620 |
%\item given an URL, read the corresponding webpage |
|
621 |
%\item if not possible print, out a problem |
|
622 |
%\item if possible, extract all links from it |
|
623 |
%\item call the web-crawler again for all these links |
|
624 |
%\end{enumerate}\bigskip\pause |
|
625 |
% |
|
626 |
%\small (we need a bound for the number of recursive calls) |
|
627 |
% |
|
628 |
%\small (the purpose is to check all links on my own webpage) |
|
629 |
%\end{frame} |
|
2 | 630 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
631 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
632 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
633 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
631 | 634 |
%\begin{frame}[c] |
635 |
% |
|
636 |
%\begin{textblock}{1}(2,5) |
|
637 |
%\begin{tabular}{c} |
|
638 |
%\includegraphics[scale=0.15]{pics/servers.png}\\[-2mm] |
|
639 |
%\small Server |
|
640 |
%\end{tabular} |
|
641 |
%\end{textblock} |
|
642 |
% |
|
643 |
%\begin{textblock}{1}(5.6,4) |
|
644 |
% \begin{tikzpicture}[scale=1.1] |
|
645 |
% \draw[white] (0,1) node (X) {}; |
|
646 |
% \draw[white] (2,1) node (Y) {}; |
|
647 |
% \draw[white] (0,0) node (X1) {}; |
|
648 |
% \draw[white] (2,0) node (Y1) {}; |
|
649 |
% \draw[white] (0,-1) node (X2) {}; |
|
650 |
% \draw[white] (2,-1) node (Y2) {}; |
|
651 |
% \draw[red, <-, line width = 2mm] (X) -- (Y); |
|
652 |
% \node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {}; |
|
653 |
% \draw[red, ->, line width = 2mm] (X1) -- (Y1); |
|
654 |
% \node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {}; |
|
655 |
% \draw[red, <-, line width = 2mm] (X2) -- (Y2); |
|
656 |
% \node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {}; |
|
657 |
% \end{tikzpicture} |
|
658 |
%\end{textblock} |
|
659 |
% |
|
660 |
% |
|
661 |
%\begin{textblock}{1}(9,5.5) |
|
662 |
%\begin{tabular}{c} |
|
663 |
%\includegraphics[scale=0.15]{pics/laptop.png}\\[-2mm] |
|
664 |
%\small Browser |
|
665 |
%\end{tabular} |
|
666 |
%\end{textblock} |
|
667 |
%\end{frame} |
|
668 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
669 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
670 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
671 |
|
0 | 672 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
631 | 673 |
%\begin{frame}[c] |
674 |
%\frametitle{Scala} |
|
675 |
% |
|
676 |
%\small A simple Scala function for reading webpages: |
|
677 |
%\bigskip |
|
678 |
% |
|
679 |
%\footnotesize |
|
680 |
%\lstinputlisting{../progs/app0.scala} |
|
681 |
%\medskip\pause |
|
682 |
% |
|
683 |
%\lstinline{get_page("""https://nms.kcl.ac.uk/christian.urban/""")} |
|
684 |
%\bigskip\medskip\pause |
|
685 |
% |
|
686 |
% |
|
687 |
%\small A slightly more complicated version for handling errors: |
|
688 |
%\smallskip |
|
689 |
% |
|
690 |
%\footnotesize |
|
691 |
%\lstinputlisting[xleftmargin=-4mm]{../progs/app1.scala} |
|
692 |
% |
|
693 |
% |
|
694 |
%\end{frame} |
|
0 | 695 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
696 |
||
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
697 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
698 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
699 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
3 | 700 |
\begin{frame}[t] |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
701 |
\frametitle{A Regular Expression} |
3 | 702 |
|
703 |
\begin{itemize} |
|
704 |
\item \ldots{} is a pattern or template for specifying strings |
|
705 |
\end{itemize}\bigskip |
|
706 |
||
707 |
\begin{center} |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
708 |
\only<1>{\scode{"https?://[^"]*"}}% |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
709 |
\only<2>{\scode{""""https?://[^"]*"""".r}} |
3 | 710 |
\end{center}\bigskip\bigskip |
711 |
||
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
712 |
matches for example\smallskip\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
713 |
\hspace{2mm}\code{"http://www.foobar.com"}\\ |
559 | 714 |
\hspace{2mm}\code{"https://www.tls.org"}\smallskip\\ |
715 |
||
716 |
but not\smallskip\\ |
|
717 |
\hspace{2mm}\code{"http://www."foo"bar.com"}\\ |
|
3 | 718 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
719 |
\end{frame} |
3 | 720 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
721 |
||
722 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
632 | 723 |
%\begin{frame}[c] |
724 |
%\frametitle{Finding Operations in Scala} |
|
725 |
% |
|
726 |
%{\bf\code{rexp.findAllIn(string)}}\medskip |
|
727 |
% |
|
728 |
%returns a list of all (sub)strings that match the |
|
729 |
%regular expression |
|
730 |
%\bigskip\bigskip |
|
731 |
% |
|
732 |
% |
|
733 |
%{\bf\code{rexp.findFirstIn(string)}}\medskip |
|
734 |
% |
|
735 |
%returns either |
|
736 |
% |
|
737 |
%\begin{itemize} |
|
738 |
%\item \code{None} if no (sub)string matches or |
|
739 |
%\item \code{Some(s)} with the first (sub)string |
|
740 |
%\end{itemize} |
|
741 |
% |
|
742 |
%\end{frame} |
|
0 | 743 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
744 |
||
745 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
631 | 746 |
%\begin{frame}[c] |
747 |
% |
|
748 |
%\footnotesize |
|
749 |
%\lstinputlisting{../progs/app2.scala} |
|
750 |
% |
|
751 |
%\end{frame} |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
752 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 753 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
754 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
631 | 755 |
%\begin{frame}[c] |
756 |
% |
|
757 |
%\small |
|
758 |
%A version that only crawls links in ``my'' domain:\bigskip |
|
759 |
% |
|
760 |
%\footnotesize |
|
761 |
%\lstinputlisting{../progs/app3.scala} |
|
762 |
% |
|
763 |
%\end{frame} |
|
0 | 764 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
765 |
||
766 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
631 | 767 |
%\begin{frame}[c] |
768 |
%\lstset{xleftmargin=-4mm} |
|
769 |
%\small |
|
770 |
%A little email harvester: |
|
771 |
% |
|
772 |
%\footnotesize |
|
773 |
%\lstinputlisting{../progs/app4.scala}\bigskip |
|
774 |
% |
|
775 |
%\tiny |
|
776 |
%\url{http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/} |
|
777 |
% |
|
778 |
%\end{frame} |
|
3 | 779 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
780 |
||
781 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
14 | 782 |
\begin{frame}[t] |
506 | 783 |
\frametitle{Regular Expressions} |
0 | 784 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
785 |
Their inductive definition: |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
786 |
|
14 | 787 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
788 |
\begin{textblock}{6}(2,7.5) |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
789 |
\begin{tabular}{@ {}rrl@ {\hspace{13mm}}l} |
512 | 790 |
\bl{$r$} & \bl{$::=$} & \bl{$\ZERO$} & nothing\\ |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
791 |
& \bl{$\mid$} & \bl{$\ONE$} & empty string / \pcode{""} / $[]$\\ |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
792 |
& \bl{$\mid$} & \bl{$c$} & character\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
793 |
& \bl{$\mid$} & \bl{$r_1 + r_2$} & alternative / choice\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
794 |
& \bl{$\mid$} & \bl{$r_1 \cdot r_2$} & sequence\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
795 |
& \bl{$\mid$} & \bl{$r^*$} & star (zero or more)\\ |
3 | 796 |
\end{tabular} |
797 |
\end{textblock} |
|
798 |
||
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
799 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
800 |
\only<2->{\footnotesize |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
801 |
\begin{textblock}{9}(2,0.5) |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
802 |
\begin{bubble}[9.8cm] |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
803 |
\lstinputlisting{../progs/app01.scala} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
804 |
\end{bubble} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
805 |
\end{textblock}} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
806 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
807 |
\end{frame} |
3 | 808 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
809 |
||
810 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
506 | 811 |
%\begin{frame}[t] |
812 |
%\frametitle{Regular Expressions} |
|
813 |
% |
|
814 |
%\small |
|
815 |
%In Scala:\bigskip |
|
816 |
% |
|
817 |
%\footnotesize |
|
818 |
%\lstinputlisting{../progs/app51.scala} |
|
819 |
% |
|
820 |
% |
|
821 |
%\end{frame} |
|
0 | 822 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
823 |
||
824 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
825 |
\begin{frame}[t] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
826 |
\frametitle{Strings} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
827 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
828 |
\ldots are lists of characters. For example \code{"hello"} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
829 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
830 |
\begin{center} |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
831 |
\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:
254
diff
changeset
|
832 |
\end{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
833 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
834 |
the empty string: \bl{$[]$} or \bl{\pcode{""}}\bigskip\\ |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
835 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
836 |
the concatenation of two strings: |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
837 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
838 |
\begin{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
839 |
\bl{$s_1 \,@\, s_2$} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
840 |
\end{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
841 |
|
631 | 842 |
\bl{\textit{foo $@$ bar = foobar}}\\ |
843 |
\bl{\textit{baz $@\, []$ = baz}} |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
844 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
845 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
846 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
847 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
848 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
849 |
\begin{frame}[c] |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
850 |
\frametitle{Languages, Strings} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
851 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
852 |
\begin{itemize} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
853 |
\item \alert{\bf Strings} are lists of characters, for example |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
854 |
\begin{center} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
855 |
\bl{$[]$},\;\bl{$abc$} \hspace{2cm}(Pattern match: \bl{$c\!::\!s$}) |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
856 |
\end{center}\bigskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
857 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
858 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
859 |
\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:
328
diff
changeset
|
860 |
\begin{center} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
861 |
\bl{$\{[], hello, \textit{foobar}, a, abc\}$} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
862 |
\end{center}\bigskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
863 |
|
332
4755ad4b457b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
864 |
\item \alert{\bf Concatenation} of strings and languages |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
865 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
866 |
\begin{center} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
867 |
\begin{tabular}{rcl} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
868 |
\bl{$\textit{foo}\;@\;bar$} & \bl{$=$} & \bl{$\textit{foobar}$}\medskip\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
869 |
\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:
328
diff
changeset
|
870 |
\end{tabular} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
871 |
\end{center} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
872 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
873 |
%\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:
328
diff
changeset
|
874 |
% strings, or language. |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
875 |
\end{itemize} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
876 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
877 |
\end{frame} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
878 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
879 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
880 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
881 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 882 |
\mode<presentation>{ |
883 |
\begin{frame}[c] |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
884 |
\frametitle{\begin{tabular}{c}The Meaning of a\\[-2mm] |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
885 |
Regular Expression\end{tabular}} |
0 | 886 |
|
4 | 887 |
\begin{textblock}{15}(1,4) |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
888 |
\begin{tabular}{rcl} |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
889 |
\bl{$L(\ZERO)$} & \bl{$\dn$} & \bl{$\{\}$}\\ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
890 |
\bl{$L(\ONE)$} & \bl{$\dn$} & \bl{$\{[]\}$}\\ |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
891 |
\bl{$L(c)$} & \bl{$\dn$} & \bl{$\{[c]\}$}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
892 |
\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:
253
diff
changeset
|
893 |
\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:
334
diff
changeset
|
894 |
\bl{$L(r^*)$} & \bl{$\dn$} & \onslide<4->{\bl{$\bigcup_{0 \le n} L(r)^n$}}\\ |
4 | 895 |
\end{tabular}\bigskip |
3 | 896 |
|
4 | 897 |
\onslide<2->{ |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
898 |
\hspace{5mm}\bl{$L(r)^0 \;\dn\; \{[]\}$}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
899 |
\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:
253
diff
changeset
|
900 |
\small\hspace{5cm}\textcolor{gray}{$\{ s_1 @ s_2 \;|\; s_1\in L(r) \wedge s_2 \in L(r)^n \}$}} |
4 | 901 |
} |
902 |
\end{textblock} |
|
903 |
||
0 | 904 |
\end{frame}} |
905 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
906 |
||
5 | 907 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
908 |
\begin{frame}[c] |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
909 |
\frametitle{The Meaning of Matching} |
5 | 910 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
911 |
\begin{bubble}[10cm] |
559 | 912 |
\large\bf |
507 | 913 |
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:
253
diff
changeset
|
914 |
provided |
5 | 915 |
|
916 |
\begin{center} |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
917 |
\bl{$s \in L(r)$}\\ |
5 | 918 |
\end{center} |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
919 |
\end{bubble}\bigskip\bigskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
920 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
921 |
\ldots and the point of the next lecture is |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
922 |
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:
334
diff
changeset
|
923 |
Ruby, Java) |
5 | 924 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
925 |
\end{frame} |
5 | 926 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
927 |
||
631 | 928 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
929 |
\begin{frame}[c] |
|
930 |
\frametitle{The Power Operation} |
|
931 |
||
932 |
\begin{itemize} |
|
933 |
\item The \alert{\textbf{\boldmath$n$th Power}} of a language: |
|
934 |
||
935 |
\begin{center} |
|
936 |
\begin{tabular}{lcl} |
|
937 |
\bl{$A^0$} & \bl{$\dn$} & \bl{$\{[]\}$}\\ |
|
938 |
\bl{$A^{n+1}$} & \bl{$\dn$} & \bl{$A \,@\, A^n$} |
|
939 |
\end{tabular} |
|
940 |
\end{center}\bigskip |
|
941 |
||
942 |
\item[] For example |
|
943 |
||
944 |
\begin{center} |
|
945 |
\begin{tabular}{lcl@{\hspace{10mm}}l} |
|
946 |
\bl{$A^4$} & \bl{$=$} & \bl{$A \,@\, A \,@\, A \,@\, A$} & \bl{$(@\,\{[]\})$}\\ |
|
947 |
\bl{$A^1$} & \bl{$=$} & \bl{$A$} & \bl{$(@\,\{[]\})$}\\ |
|
948 |
\bl{$A^0$} & \bl{$=$} & \bl{$\{[]\}$}\\ |
|
949 |
\end{tabular} |
|
950 |
\end{center} |
|
951 |
||
952 |
\end{itemize} |
|
953 |
||
954 |
\end{frame} |
|
955 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
956 |
||
957 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
958 |
\begin{frame}[c] |
|
959 |
\frametitle{Questions} |
|
960 |
||
961 |
\begin{itemize} |
|
962 |
\item Say \bl{$A = \{[a],[b],[c],[d]\}$}.\bigskip |
|
963 |
||
964 |
\item[] |
|
965 |
How many strings are in \bl{$A^4$}\,? |
|
966 |
\bigskip\medskip\pause |
|
967 |
||
968 |
||
969 |
\item[] |
|
970 |
What if \bl{$A = \{[a],[b],[c],[]\}$};\\ |
|
971 |
how many strings are then in \bl{$A^4$}\,? |
|
972 |
\end{itemize} |
|
973 |
||
974 |
\end{frame} |
|
975 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
976 |
||
977 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
978 |
\begin{frame}[c] |
|
743 | 979 |
\frametitle{Languages (Sets of Strings)} |
980 |
||
981 |
\begin{itemize} |
|
982 |
||
983 |
\item A \alert{\bf Language} is a set of strings, for example\medskip |
|
984 |
\begin{center} |
|
985 |
\bl{$\{[], hello, foobar, a, abc\}$} |
|
986 |
\end{center}\bigskip |
|
987 |
||
988 |
\item \alert{\bf Concatenation} for strings and languages |
|
989 |
||
990 |
\begin{center} |
|
991 |
\begin{tabular}{rcl} |
|
992 |
\bl{$foo\;@\;bar$} & \bl{$=$} & \bl{$foobar$}\medskip\\ |
|
993 |
\bl{$A\;@\;B$} & \bl{$\dn$} & \bl{$\{ s_1\,@\,s_2 \;\mid\; s_1 \in A \wedge s_2 \in B\}$} |
|
994 |
\end{tabular} |
|
995 |
\end{center} |
|
996 |
\bigskip |
|
997 |
||
998 |
\small |
|
999 |
\item [] For example \bl{$A = \{foo, bar\}$}, \bl{$B = \{a, b\}$} |
|
1000 |
||
1001 |
\[ |
|
1002 |
\bl{A \,@\, B = \{fooa, foob, bara, barb\}} |
|
1003 |
\] |
|
1004 |
||
1005 |
\end{itemize} |
|
1006 |
\end{frame} |
|
1007 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1008 |
||
1009 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1010 |
\begin{frame}[c] |
|
1011 |
\frametitle{Two Corner Cases} |
|
1012 |
||
1013 |
\Large |
|
1014 |
\begin{center} |
|
1015 |
\bl{$A \,@\, \{[]\} = \;?$}\bigskip\bigskip\pause\\ |
|
1016 |
\bl{$A \,@\, \{\} = \;?$} |
|
1017 |
\end{center} |
|
1018 |
||
1019 |
\end{frame} |
|
1020 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1021 |
||
1022 |
||
1023 |
||
1024 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1025 |
\begin{frame}[c] |
|
1026 |
\frametitle{ |
|
1027 |
The Meaning of a\\[-2mm] |
|
1028 |
Regular Expression} |
|
1029 |
||
1030 |
...all the strings a regular expression can match. |
|
1031 |
||
1032 |
\begin{center} |
|
1033 |
\begin{tabular}{rcl} |
|
1034 |
\bl{$L(\ZERO)$} & \bl{$\dn$} & \bl{$\{\}$}\\ |
|
1035 |
\bl{$L(\ONE)$} & \bl{$\dn$} & \bl{$\{[]\}$}\\ |
|
1036 |
\bl{$L(c)$} & \bl{$\dn$} & \bl{$\{[c]\}$}\\ |
|
1037 |
\bl{$L(r_1 + r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\ |
|
1038 |
\bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \,@\, L(r_2)$}\\ |
|
1039 |
\bl{$L(r^*)$} & \bl{$\dn$} & \\ |
|
1040 |
\end{tabular} |
|
1041 |
\end{center} |
|
1042 |
||
1043 |
\begin{textblock}{14}(1.5,13.5)\small |
|
1044 |
\bl{$L$} is a function from regular expressions to |
|
1045 |
sets of strings (languages):\smallskip\\ |
|
1046 |
\bl{\quad$L$ : Rexp $\Rightarrow$ Set$[$String$]$} |
|
1047 |
\end{textblock} |
|
1048 |
||
1049 |
\end{frame} |
|
1050 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1051 |
||
1052 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1053 |
\begin{frame}[c] |
|
1054 |
\frametitle{The Power Operation} |
|
1055 |
||
1056 |
\begin{itemize} |
|
1057 |
\item The \alert{\textbf{\boldmath$n$th Power}} of a language: |
|
1058 |
||
1059 |
\begin{center} |
|
1060 |
\begin{tabular}{lcl} |
|
1061 |
\bl{$A^0$} & \bl{$\dn$} & \bl{$\{[]\}$}\\ |
|
1062 |
\bl{$A^{n+1}$} & \bl{$\dn$} & \bl{$A \,@\, A^n$} |
|
1063 |
\end{tabular} |
|
1064 |
\end{center}\bigskip |
|
1065 |
||
1066 |
\item[] For example |
|
1067 |
||
1068 |
\begin{center} |
|
1069 |
\begin{tabular}{lcl@{\hspace{10mm}}l} |
|
1070 |
\bl{$A^4$} & \bl{$=$} & \bl{$A \,@\, A \,@\, A \,@\, A$} & \bl{$(@\,\{[]\})$}\\ |
|
1071 |
\bl{$A^1$} & \bl{$=$} & \bl{$A$} & \bl{$(@\,\{[]\})$}\\ |
|
1072 |
\bl{$A^0$} & \bl{$=$} & \bl{$\{[]\}$}\\ |
|
1073 |
\end{tabular} |
|
1074 |
\end{center} |
|
1075 |
||
1076 |
\end{itemize} |
|
1077 |
||
1078 |
\end{frame} |
|
1079 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1080 |
||
1081 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1082 |
\begin{frame}[c] |
|
631 | 1083 |
\frametitle{The Star Operation} |
1084 |
||
1085 |
\begin{itemize} |
|
1086 |
\item The \alert{\bf Kleene Star} of a \underline{language}: |
|
1087 |
\bigskip |
|
1088 |
||
1089 |
\begin{center} |
|
1090 |
\begin{tabular}{c} |
|
1091 |
\bl{$A\star \dn \bigcup_{0\le n} A^n$} |
|
1092 |
\end{tabular} |
|
1093 |
\end{center}\bigskip |
|
1094 |
||
1095 |
\item[] This expands to |
|
1096 |
||
1097 |
\[ |
|
1098 |
\bl{A^0 \cup A^1 \cup A^2 \cup A^3 \cup A^4 \cup \ldots} |
|
1099 |
\] |
|
1100 |
||
1101 |
or |
|
1102 |
||
1103 |
\small |
|
1104 |
\[ |
|
1105 |
\bl{\{[]\} \;\cup\; A \;\cup\; A\,@\,A \;\cup\; |
|
1106 |
A\,@\,A\,@\,A \;\cup\; A\,@\,A\,@\,A\,@\,A \cup \ldots} |
|
1107 |
\] |
|
1108 |
||
1109 |
\end{itemize} |
|
1110 |
||
1111 |
\end{frame} |
|
1112 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1113 |
||
1114 |
||
0 | 1115 |
|
1116 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1117 |
\begin{frame}[c] |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1118 |
\frametitle{Written Exam} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1119 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1120 |
\begin{itemize} |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
1121 |
\item Accounts for 80\%.\bigskip |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1122 |
|
559 | 1123 |
\item The question ``\textit{Is this relevant for |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
1124 |
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:
252
diff
changeset
|
1125 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1126 |
\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:
328
diff
changeset
|
1127 |
``\textit{optional}'') is relevant for the exam.\bigskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
1128 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
1129 |
\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:
328
diff
changeset
|
1130 |
notation and Scala. |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1131 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1132 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1133 |
\end{frame} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1134 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1135 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1136 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1137 |
\begin{frame}[t] |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1138 |
\frametitle{Coursework} |
0 | 1139 |
|
1140 |
\begin{itemize} |
|
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
1141 |
\item Accounts for 20\%. Two strands. Choose \alert{\bf one}!\bigskip |
0 | 1142 |
\end{itemize} |
1143 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
1144 |
\begin{columns}[t] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
1145 |
\begin{column}{.5\textwidth} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
1146 |
\underline{\bf Strand 1}\medskip |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1147 |
\begin{itemize} |
631 | 1148 |
\item 4 programming tasks: |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1149 |
\begin{itemize} |
631 | 1150 |
\item matcher (4\%, 11.10.) |
1151 |
\item lexer (5\%, 04.11.) |
|
1152 |
\item parser (5\%, 22.11.) |
|
1153 |
\item compiler (6\%, 13.12.) |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1154 |
\end{itemize} |
631 | 1155 |
\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:
252
diff
changeset
|
1156 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1157 |
\end{column} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1158 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1159 |
\hspace{-45pt}\vrule{}\hspace{10pt} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
1160 |
\begin{column}{.5\textwidth} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
1161 |
\underline{\bf Strand 2}\smallskip\begin{itemize} |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1162 |
\item one task: prove the correctness of a regular expression matcher in |
559 | 1163 |
the \underline{Isabelle} theorem prover |
631 | 1164 |
\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:
252
diff
changeset
|
1165 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1166 |
\end{column} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1167 |
\end{columns}\medskip |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1168 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1169 |
\small |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1170 |
\begin{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1171 |
\item Solving more than one strand will {\bf not} give you more |
506 | 1172 |
marks. |
1173 |
||
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1174 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1175 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
1176 |
\end{frame} |
0 | 1177 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1178 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
1179 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
1180 |
\begin{frame}[c] |
506 | 1181 |
\frametitle{Lecture Capture} |
1182 |
||
1183 |
\begin{itemize} |
|
559 | 1184 |
\item Hope it works\ldots\pause actually no, it does not!\medskip\pause |
1185 |
\item It is important to use lecture capture wisely\\ (it is only the ``baseline''): |
|
506 | 1186 |
\begin{itemize} |
1187 |
\item Lecture recordings are a study and revision aid. |
|
1188 |
\item Statistically, there is a clear and direct link between attendance and |
|
637 | 1189 |
attainment: students who do not attend lectures, do less well in exams. |
506 | 1190 |
\end{itemize} |
1191 |
||
1192 |
\item Attending a lecture is more than watching it online -- if you do not |
|
1193 |
attend, you miss out! |
|
1194 |
||
1195 |
\end{itemize} |
|
1196 |
||
1197 |
\end{frame} |
|
1198 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1199 |
||
1200 |
||
1201 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1202 |
\begin{frame}[c] |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
1203 |
\frametitle{\begin{tabular}{c}\\[3cm]\alert{Questions?}\end{tabular}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
1204 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
1205 |
\mbox{} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
1206 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
1207 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 1208 |
\end{document} |
1209 |
||
1210 |
%%% Local Variables: |
|
1211 |
%%% mode: latex |
|
1212 |
%%% TeX-master: t |
|
1213 |
%%% End: |
|
1214 |