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