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