author | Christian Urban <urbanc@in.tum.de> |
Thu, 19 Apr 2018 13:57:17 +0100 | |
changeset 3245 | 017e33849f4d |
parent 3224 | cf451e182bf0 |
permissions | -rw-r--r-- |
2459 | 1 |
(*<*) |
2 |
theory Slides4 |
|
3224
cf451e182bf0
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
2748
diff
changeset
|
3 |
imports "~~/src/HOL/Library/LaTeXsugar" "../Nominal/Nominal2" |
2459 | 4 |
begin |
5 |
||
2748
6f38e357b337
rearranged directories and updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents:
2459
diff
changeset
|
6 |
declare [[show_question_marks = false]] |
6f38e357b337
rearranged directories and updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents:
2459
diff
changeset
|
7 |
|
2459 | 8 |
notation (latex output) |
9 |
set ("_") and |
|
10 |
Cons ("_::/_" [66,65] 65) |
|
11 |
||
12 |
(*>*) |
|
13 |
||
14 |
text_raw {* |
|
15 |
\renewcommand{\slidecaption}{Nanjing, 31.~August 2010} |
|
16 |
||
17 |
\newcommand{\abst}[2]{#1.#2}% atom-abstraction |
|
18 |
\newcommand{\pair}[2]{\langle #1,#2\rangle} % pairing |
|
19 |
\newcommand{\susp}{{\boldsymbol{\cdot}}}% for suspensions |
|
20 |
\newcommand{\unit}{\langle\rangle}% unit |
|
21 |
\newcommand{\app}[2]{#1\,#2}% application |
|
22 |
\newcommand{\eqprob}{\mathrel{{\approx}?}} |
|
23 |
\newcommand{\freshprob}{\mathrel{\#?}} |
|
24 |
\newcommand{\redu}[1]{\stackrel{#1}{\Longrightarrow}}% reduction |
|
25 |
\newcommand{\id}{\varepsilon}% identity substitution |
|
26 |
||
27 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}} |
|
28 |
\newcommand{\gr}[1]{\textcolor{gray}{#1}} |
|
29 |
\newcommand{\rd}[1]{\textcolor{red}{#1}} |
|
30 |
||
31 |
\newcommand{\ok}{\includegraphics[scale=0.07]{ok.png}} |
|
32 |
\newcommand{\notok}{\includegraphics[scale=0.07]{notok.png}} |
|
33 |
\newcommand{\largenotok}{\includegraphics[scale=1]{notok.png}} |
|
34 |
||
35 |
\renewcommand{\Huge}{\fontsize{61.92}{77}\selectfont} |
|
36 |
\newcommand{\veryHuge}{\fontsize{74.3}{93}\selectfont} |
|
37 |
\newcommand{\VeryHuge}{\fontsize{89.16}{112}\selectfont} |
|
38 |
\newcommand{\VERYHuge}{\fontsize{107}{134}\selectfont} |
|
39 |
||
40 |
\newcommand{\LL}{$\mathbb{L}\,$} |
|
41 |
||
42 |
||
43 |
\pgfdeclareradialshading{smallbluesphere}{\pgfpoint{0.5mm}{0.5mm}}% |
|
44 |
{rgb(0mm)=(0,0,0.9); |
|
45 |
rgb(0.9mm)=(0,0,0.7); |
|
46 |
rgb(1.3mm)=(0,0,0.5); |
|
47 |
rgb(1.4mm)=(1,1,1)} |
|
48 |
||
49 |
\def\myitemi{\begin{pgfpicture}{-1ex}{-0.55ex}{1ex}{1ex} |
|
50 |
\usebeamercolor[fg]{subitem projected} |
|
51 |
{\pgftransformscale{0.8}\pgftext{\normalsize\pgfuseshading{bigsphere}}} |
|
52 |
\pgftext{% |
|
53 |
\usebeamerfont*{subitem projected}} |
|
54 |
\end{pgfpicture}} |
|
55 |
||
56 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
57 |
\mode<presentation>{ |
|
58 |
\begin{frame}<1>[t] |
|
59 |
\frametitle{% |
|
60 |
\begin{tabular}{@ {\hspace{-3mm}}c@ {}} |
|
61 |
\\ |
|
62 |
\huge Error-Free Programming\\[-1mm] |
|
63 |
\huge with Theorem Provers\\[5mm] |
|
64 |
\end{tabular}} |
|
65 |
\begin{center} |
|
66 |
Christian Urban |
|
67 |
\end{center} |
|
68 |
\begin{center} |
|
69 |
\small Technical University of Munich, Germany\\[7mm] |
|
70 |
||
71 |
\small in Nanjing on the kind invitation of\\ Professor Xingyuan Zhang |
|
72 |
and his group |
|
73 |
\end{center} |
|
74 |
\end{frame}} |
|
75 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
76 |
||
77 |
*} |
|
78 |
text_raw {* |
|
79 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
80 |
\mode<presentation>{ |
|
81 |
\begin{frame}<1->[c] |
|
82 |
\frametitle{My Background} |
|
83 |
||
84 |
\begin{itemize} |
|
85 |
\item researcher in Theoretical Computer Science\medskip |
|
86 |
||
87 |
\item programmer on a \alert<2->{software system} with 800 kloc (though I am |
|
88 |
responsible only for 35 kloc) |
|
89 |
\end{itemize} |
|
90 |
||
91 |
\only<2->{ |
|
92 |
\begin{textblock}{6}(2,11) |
|
93 |
\begin{tikzpicture} |
|
94 |
\draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
|
95 |
{\color{darkgray} |
|
96 |
\begin{minipage}{4cm}\raggedright |
|
97 |
A theorem prover called {\bf Isabelle}. |
|
98 |
\end{minipage}}; |
|
99 |
\end{tikzpicture} |
|
100 |
\end{textblock}} |
|
101 |
||
102 |
||
103 |
\only<3>{ |
|
104 |
\begin{textblock}{6}(9,11) |
|
105 |
\begin{tikzpicture} |
|
106 |
\draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
|
107 |
{\color{darkgray} |
|
108 |
\begin{minipage}{4cm}\raggedright |
|
109 |
Like every other code, this code is very hard to |
|
110 |
get correct. |
|
111 |
\end{minipage}}; |
|
112 |
\end{tikzpicture} |
|
113 |
\end{textblock}} |
|
114 |
||
115 |
\end{frame}} |
|
116 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
117 |
*} |
|
118 |
||
119 |
text_raw {* |
|
120 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
121 |
\mode<presentation>{ |
|
122 |
\begin{frame}<1->[t] |
|
123 |
\frametitle{Regular Expressions} |
|
124 |
||
125 |
An example many (should) know about:\\ |
|
126 |
\rd{\bf Regular Expressions:} |
|
127 |
||
128 |
\only<2>{ |
|
129 |
\begin{center} |
|
130 |
\bl{[] $\;\;\;|\;\;\;$ c $\;\;\;|\;\;\;$ r$_1$$|$r$_2$ $\;\;\;|\;\;\;$ |
|
131 |
r$_1$$\cdot$r$_2$ $\;\;\;|\;\;\;$ r$^*$} |
|
132 |
\end{center}} |
|
133 |
\only<3->{ |
|
134 |
\begin{center} |
|
135 |
\begin{tabular}{@ {}rrll@ {}} |
|
136 |
\bl{r} & \bl{$::=$} & \bl{NULL} & \gr{(matches no string)}\\ |
|
137 |
& \bl{$\mid$} & \bl{EMPTY} & \gr{(matches the empty string, [])}\\ |
|
138 |
& \bl{$\mid$} & \bl{CHR c} & \gr{(matches the character c)}\\ |
|
139 |
& \bl{$\mid$} & \bl{ALT r$_1$ r$_2$} & \gr{(alternative, r$_1 |\,$r$_2$)}\\ |
|
140 |
& \bl{$\mid$} & \bl{SEQ r$_1$ r$_2$} & \gr{(sequential, r$_1\cdot\,$r$_2$)}\\ |
|
141 |
& \bl{$\mid$} & \bl{STAR r} & \gr{(repeat, r$^*$)}\\ |
|
142 |
\end{tabular} |
|
143 |
\end{center}\medskip} |
|
144 |
||
145 |
\small |
|
146 |
\begin{textblock}{14.5}(1,12.5) |
|
147 |
\only<2->{\gr{(a$\cdot$b)$^*$ \hspace{3mm}$\mapsto$\hspace{3mm} \{[], ab, abab, ababab, \ldots\}}\\} |
|
148 |
\only<2->{\gr{x$\cdot$(0 $|$ 1 $|$ 2 \ldots 8 $|$ 9)$^*$ \hspace{3mm}$\mapsto$\hspace{3mm} |
|
149 |
\{x, x0, x1, \ldots, x00, \ldots, x123, \ldots\}}} |
|
150 |
\end{textblock} |
|
151 |
\end{frame}} |
|
152 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
153 |
*} |
|
154 |
||
155 |
text_raw {* |
|
156 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
157 |
\mode<presentation>{ |
|
158 |
\begin{frame}<1>[c] |
|
159 |
\frametitle{RegExp Matcher} |
|
160 |
||
161 |
Let's implement a regular expression matcher:\bigskip |
|
162 |
||
163 |
\begin{center} |
|
164 |
\begin{tikzpicture} |
|
165 |
%%\draw[help lines, black] (-3,0) grid (6,3); |
|
166 |
||
167 |
\draw[line width=1mm, red] (0.0,0.0) rectangle (4,2.3); |
|
168 |
\node[anchor=base] at (2,1) |
|
169 |
{\small\begin{tabular}{@ {}c@ {}}\Large\bf Regular\\ |
|
170 |
\Large\bf Expression \\ |
|
171 |
\Large\bf Matcher\end{tabular}}; |
|
172 |
||
173 |
\coordinate (m1) at (0,1.5); |
|
174 |
\draw (-2,2) node (m2) {\small\begin{tabular}{c}\bl{regular}\\[-1mm] \bl{expression}\end{tabular}}; |
|
175 |
\path[overlay, ->, line width = 1mm, shorten <=-3mm] (m2) edge (m1); |
|
176 |
||
177 |
\coordinate (s1) at (0,0.5); |
|
178 |
\draw (-1.8,-0) node (s2) {\small\begin{tabular}{c}\bl{string}\end{tabular}}; |
|
179 |
\path[overlay, ->, line width = 1mm, shorten <=-3mm] (s2) edge (s1); |
|
180 |
||
181 |
\coordinate (r1) at (4,1.2); |
|
182 |
\draw (6,1.2) node (r2) {\small\begin{tabular}{c}\bl{true}, \bl{false}\end{tabular}}; |
|
183 |
\path[overlay, ->, line width = 1mm, shorten >=-3mm] (r1) edge (r2); |
|
184 |
||
185 |
\end{tikzpicture} |
|
186 |
\end{center} |
|
187 |
||
188 |
||
189 |
\end{frame}} |
|
190 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
191 |
*} |
|
192 |
||
193 |
text_raw {* |
|
194 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
195 |
\mode<presentation>{ |
|
196 |
\begin{frame}<1->[t] |
|
197 |
\frametitle{RegExp Matcher} |
|
198 |
\small |
|
199 |
||
200 |
{\bf input:} a \underline{list} of RegExps and a string \hspace{6mm}{\bf output:} true or false |
|
201 |
||
202 |
\only<2->{ |
|
203 |
\begin{center} |
|
204 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
|
205 |
\bl{match [] []} & \bl{$=$} & \bl{true}\\ |
|
206 |
\bl{match [] \_} & \bl{$=$} & \bl{false}\\ |
|
207 |
\bl{match (NULL::rs) s} & \bl{$=$} & \bl{false}\\ |
|
208 |
\bl{match (EMPTY::rs) s} & \bl{$=$} & \bl{match rs s}\\ |
|
209 |
\bl{match (CHR c::rs) (c::s)} & \bl{$=$} & \bl{match rs s}\\ |
|
210 |
\bl{match (CHR c::rs) \_} & \bl{$=$} & \bl{false}\\ |
|
211 |
\bl{match (ALT r$_1$ r$_2$::rs) s} & \bl{$=$} & \bl{match (r$_1$::rs) s}\\ |
|
212 |
& & \bl{\;\;\;\;orelse match (r$_2$::rs) s}\\ |
|
213 |
\bl{match (SEQ r$_1$ r$_2$::rs) s} & \bl{$=$} & \bl{match (r$_1$::r$_2$::rs) s}\\ |
|
214 |
\bl{match (STAR r::rs) s} & \bl{$=$} & \bl{match rs s}\\ |
|
215 |
& & \bl{\;\;\;\;orelse match (r::STAR r::rs) s}\\ |
|
216 |
\end{tabular} |
|
217 |
\end{center}} |
|
218 |
||
219 |
\onslide<3->{we start the program with\\ |
|
220 |
\hspace{6mm}\bl{matches r s $=$ match [r] s}} |
|
221 |
||
222 |
\end{frame}} |
|
223 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
224 |
*} |
|
225 |
||
226 |
||
227 |
text_raw {* |
|
228 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
229 |
\mode<presentation>{ |
|
230 |
\begin{frame}<1>[c] |
|
231 |
\frametitle{Program in Scala} |
|
232 |
||
233 |
\bl{\footnotesize |
|
234 |
\begin{tabular}{l} |
|
235 |
sealed abstract class Rexp\\ |
|
236 |
sealed case class Null extends Rexp\\ |
|
237 |
sealed case class Empty extends Rexp\\ |
|
238 |
sealed case class Chr(c: Char) extends Rexp\\ |
|
239 |
sealed case class Alt(r1 : Rexp, r2 : Rexp) extends Rexp\\ |
|
240 |
sealed case class Seq(r1 : Rexp, r2 : Rexp) extends Rexp\\ |
|
241 |
sealed case class Star(r : Rexp) extends Rexp\medskip\\ |
|
242 |
def match1 (rs : List[Rexp], s : List[Char]) : Boolean = rs match \{\\ |
|
243 |
\hspace{3mm}case Nil @{text "\<Rightarrow>"} if (s == Nil) true else false\\ |
|
244 |
\hspace{3mm}case (Null()::rs) @{text "\<Rightarrow>"} false\\ |
|
245 |
\hspace{3mm}case (Empty()::rs) @{text "\<Rightarrow>"} match1 (rs, s)\\ |
|
246 |
\hspace{3mm}case (Chr(c)::rs) @{text "\<Rightarrow>"} s match \\ |
|
247 |
\hspace{6mm}\{ case Nil @{text "\<Rightarrow>"} false\\ |
|
248 |
\hspace{8mm}case (d::s) @{text "\<Rightarrow>"} if (c==d) match1 (rs,s) else false \}\\ |
|
249 |
\hspace{3mm}case (Alt (r1, r2)::rs) @{text "\<Rightarrow>"} match1 (r1::rs, s) || match1 (r2::rs, s)\\ |
|
250 |
\hspace{3mm}case (Seq (r1, r2)::rs) @{text "\<Rightarrow>"} match1 (r1::r2::rs, s) \\ |
|
251 |
\hspace{3mm}case (Star (r)::rs) @{text "\<Rightarrow>"} match1 (r::rs, s) || match1 (r::Star (r)::rs, s)\\ |
|
252 |
\} |
|
253 |
\end{tabular}} |
|
254 |
||
255 |
\end{frame}} |
|
256 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
257 |
*} |
|
258 |
||
259 |
||
260 |
text_raw {* |
|
261 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
262 |
\mode<presentation>{ |
|
263 |
\begin{frame}<1->[c] |
|
264 |
\frametitle{Testing} |
|
265 |
||
266 |
\small |
|
267 |
Every good programmer should do thourough tests: |
|
268 |
||
269 |
||
270 |
\begin{center} |
|
271 |
\begin{tabular}{@ {\hspace{-20mm}}lcl} |
|
272 |
\bl{matches (a$\cdot$b)$^*\;$ []} & \bl{$\mapsto$} & \bl{true}\\ |
|
273 |
\bl{matches (a$\cdot$b)$^*\;$ ab} & \bl{$\mapsto$} & \bl{true}\\ |
|
274 |
\bl{matches (a$\cdot$b)$^*\;$ aba} & \bl{$\mapsto$} & \bl{false}\\ |
|
275 |
\bl{matches (a$\cdot$b)$^*\;$ abab} & \bl{$\mapsto$} & \bl{true}\\ |
|
276 |
\bl{matches (a$\cdot$b)$^*\;$ abaa} & \bl{$\mapsto$} & \bl{false}\medskip\\ |
|
277 |
\onslide<2->{\bl{matches x$\cdot$(0$|$1)$^*\;$ x} & \bl{$\mapsto$} & \bl{true}}\\ |
|
278 |
\onslide<2->{\bl{matches x$\cdot$(0$|$1)$^*\;$ x0} & \bl{$\mapsto$} & \bl{true}}\\ |
|
279 |
\onslide<2->{\bl{matches x$\cdot$(0$|$1)$^*\;$ x3} & \bl{$\mapsto$} & \bl{false}} |
|
280 |
\end{tabular} |
|
281 |
\end{center} |
|
282 |
||
283 |
\onslide<3-> |
|
284 |
{looks OK \ldots let's ship it to customers\hspace{5mm} |
|
285 |
\raisebox{-5mm}{\includegraphics[scale=0.05]{sun.png}}} |
|
286 |
||
287 |
\end{frame}} |
|
288 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
289 |
*} |
|
290 |
||
291 |
text_raw {* |
|
292 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
293 |
\mode<presentation>{ |
|
294 |
\begin{frame}<1->[t] |
|
295 |
\frametitle{Testing} |
|
296 |
||
297 |
\begin{itemize} |
|
298 |
\item While testing is an important part in the process of programming development\pause |
|
299 |
||
300 |
\item we can only test a {\bf finite} amount of examples\bigskip\pause |
|
301 |
||
302 |
\begin{center} |
|
303 |
\colorbox{cream} |
|
304 |
{\gr{\begin{minipage}{10cm} |
|
305 |
``Testing can only show the presence of errors, never their |
|
306 |
absence'' (Edsger W.~Dijkstra) |
|
307 |
\end{minipage}}} |
|
308 |
\end{center}\bigskip\pause |
|
309 |
||
310 |
\item In a theorem prover we can establish properties that apply to |
|
311 |
{\bf all} input and {\bf all} output.\pause |
|
312 |
||
313 |
\item For example we can establish that the matcher terminates |
|
314 |
on all input. |
|
315 |
\end{itemize} |
|
316 |
||
317 |
\end{frame}} |
|
318 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
319 |
*} |
|
320 |
||
321 |
text_raw {* |
|
322 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
323 |
\mode<presentation>{ |
|
324 |
\begin{frame}<1->[t] |
|
325 |
\frametitle{RegExp Matcher} |
|
326 |
||
327 |
\small |
|
328 |
We need to find a measure that gets smaller in each recursive call.\bigskip |
|
329 |
||
330 |
\onslide<1->{ |
|
331 |
\begin{center} |
|
332 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {\hspace{-9mm}}l@ {}} |
|
333 |
\bl{match [] []} & \bl{$=$} & \bl{true} & \onslide<2->{\ok}\\ |
|
334 |
\bl{match [] \_} & \bl{$=$} & \bl{false} & \onslide<2->{\ok}\\ |
|
335 |
\bl{match (NULL::rs) s} & \bl{$=$} & \bl{false} & \onslide<2->{\ok}\\ |
|
336 |
\bl{match (EMPTY::rs) s} & \bl{$=$} & \bl{match rs s} & \onslide<3->{\ok}\\ |
|
337 |
\bl{match (CHR c::rs) (c::s)} & \bl{$=$} & \bl{match rs s} & \onslide<4->{\ok}\\ |
|
338 |
\bl{match (CHR c::rs) \_} & \bl{$=$} & \bl{false} & \onslide<2->{\ok}\\ |
|
339 |
\bl{match (ALT r$_1$ r$_2$::rs) s} & \bl{$=$} & \bl{match (r$_1$::rs) s} & \onslide<5->{\ok}\\ |
|
340 |
& & \bl{\;\;\;\;orelse match (r$_2$::rs) s}\\ |
|
341 |
\bl{match (SEQ r$_1$ r$_2$::rs) s} & \bl{$=$} & \bl{match (r$_1$::r$_2$::rs) s} & \onslide<6->{\ok}\\ |
|
342 |
\bl{match (STAR r::rs) s} & \bl{$=$} & \bl{match rs s} & \onslide<7->{\notok}\\ |
|
343 |
& & \bl{\;\;\;\;orelse match (r::STAR r::rs) s}\\ |
|
344 |
\end{tabular} |
|
345 |
\end{center}} |
|
346 |
||
347 |
||
348 |
\begin{textblock}{5}(4,4) |
|
349 |
\begin{tikzpicture} |
|
350 |
%%\draw[help lines, black] (-3,0) grid (6,3); |
|
351 |
||
352 |
\coordinate (m1) at (-2,0); |
|
353 |
\coordinate (m2) at ( 2,0); |
|
354 |
\path[overlay, ->, line width = 0.6mm, color = red] (m1) edge (m2); |
|
355 |
\draw (0,0) node[above=-1mm] {\footnotesize\rd{needs to get smaller}}; |
|
356 |
\end{tikzpicture} |
|
357 |
\end{textblock} |
|
358 |
||
359 |
||
360 |
\end{frame}} |
|
361 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
362 |
*} |
|
363 |
||
364 |
text_raw {* |
|
365 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
366 |
\mode<presentation>{ |
|
367 |
\begin{frame}<1->[c] |
|
368 |
\frametitle{Bug Hunting} |
|
369 |
||
370 |
\only<1>{Several hours later\ldots}\pause |
|
371 |
||
372 |
||
373 |
\begin{center} |
|
374 |
\begin{tabular}{@ {\hspace{-20mm}}lcl} |
|
375 |
\bl{matches (STAR (EMPTY)) s} & \bl{$\mapsto$} & loops\\ |
|
376 |
\onslide<4->{\bl{matches (STAR (EMPTY $|$ \ldots)) s} & \bl{$\mapsto$} & loops\\} |
|
377 |
\end{tabular} |
|
378 |
\end{center} |
|
379 |
||
380 |
\small |
|
381 |
\onslide<3->{ |
|
382 |
\begin{center} |
|
383 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
|
384 |
\ldots\\ |
|
385 |
\bl{match (EMPTY::rs) s} & \bl{$=$} & \bl{match rs s}\\ |
|
386 |
\ldots\\ |
|
387 |
\bl{match (STAR r::rs) s} & \bl{$=$} & \bl{match rs s}\\ |
|
388 |
& & \bl{\;\;\;\;orelse match (r::STAR r::rs) s}\\ |
|
389 |
\end{tabular} |
|
390 |
\end{center}} |
|
391 |
||
392 |
||
393 |
\end{frame}} |
|
394 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
395 |
*} |
|
396 |
||
397 |
text_raw {* |
|
398 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
399 |
\mode<presentation>{ |
|
400 |
\begin{frame}<1->[c] |
|
401 |
\frametitle{RegExp Matcher} |
|
402 |
\small |
|
403 |
||
404 |
\begin{center} |
|
405 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
|
406 |
\bl{match [] []} & \bl{$=$} & \bl{true}\\ |
|
407 |
\bl{match [] \_} & \bl{$=$} & \bl{false}\\ |
|
408 |
\bl{match (NULL::rs) s} & \bl{$=$} & \bl{false}\\ |
|
409 |
\bl{match (EMPTY::rs) s} & \bl{$=$} & \bl{match rs s}\\ |
|
410 |
\bl{match (CHR c::rs) (c::s)} & \bl{$=$} & \bl{match rs s}\\ |
|
411 |
\bl{match (CHR c::rs) \_} & \bl{$=$} & \bl{false}\\ |
|
412 |
\bl{match (ALT r$_1$ r$_2$::rs) s} & \bl{$=$} & \bl{match (r$_1$::rs) s}\\ |
|
413 |
& & \bl{\;\;\;\;orelse match (r$_2$::rs) s}\\ |
|
414 |
\bl{match (SEQ r$_1$ r$_2$::rs) s} & \bl{$=$} & \bl{match (r$_1$::r$_2$::rs) s}\\ |
|
415 |
\bl{match (STAR r::rs) s} & \bl{$=$} & \bl{match rs s}\\ |
|
416 |
& & \bl{\;\;\;\;orelse match (r::STAR r::rs) s}\\ |
|
417 |
\end{tabular} |
|
418 |
\end{center} |
|
419 |
||
420 |
\only<1>{ |
|
421 |
\begin{textblock}{5}(4,4) |
|
422 |
\largenotok |
|
423 |
\end{textblock}} |
|
424 |
||
425 |
\end{frame}} |
|
426 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
427 |
*} |
|
428 |
||
429 |
||
430 |
||
431 |
text_raw {* |
|
432 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
433 |
\mode<presentation>{ |
|
434 |
\begin{frame}<1->[t] |
|
435 |
\frametitle{Second Attempt} |
|
436 |
||
437 |
Can a regular expression match the empty string? |
|
438 |
||
439 |
\small |
|
440 |
\begin{center} |
|
441 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}ll@ {}} |
|
442 |
\bl{nullable (NULL)} & \bl{$=$} & \bl{false} & \onslide<2->{\ok}\\ |
|
443 |
\bl{nullable (EMPTY)} & \bl{$=$} & \bl{true} & \onslide<2->{\ok}\\ |
|
444 |
\bl{nullable (CHR c)} & \bl{$=$} & \bl{false} & \onslide<2->{\ok}\\ |
|
445 |
\bl{nullable (ALT r$_1$ r$_2$)} & \bl{$=$} & \bl{(nullable r$_1$) orelse (nullable r$_2$)} |
|
446 |
& \onslide<2->{\ok}\\ |
|
447 |
\bl{nullable (SEQ r$_1$ r$_2$)} & \bl{$=$} & \bl{(nullable r$_1$) andalso (nullable r$_2$)} |
|
448 |
& \onslide<2->{\ok}\\ |
|
449 |
\bl{nullable (STAR r)} & \bl{$=$} & \bl{true} & \onslide<2->{\ok}\\ |
|
450 |
\end{tabular} |
|
451 |
\end{center} |
|
452 |
||
453 |
\end{frame}} |
|
454 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
455 |
*} |
|
456 |
||
457 |
||
458 |
text_raw {* |
|
459 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
460 |
\mode<presentation>{ |
|
461 |
\begin{frame}<1->[t] |
|
462 |
\frametitle{RegExp Matcher 2} |
|
463 |
||
464 |
If \bl{r} matches \bl{c::s}, which regular expression can match the string \bl{s}? |
|
465 |
||
466 |
\small |
|
467 |
\begin{center} |
|
468 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {\hspace{-10mm}}l@ {}} |
|
469 |
\bl{der c (NULL)} & \bl{$=$} & \bl{NULL} & \onslide<3->{\ok}\\ |
|
470 |
\bl{der c (EMPTY)} & \bl{$=$} & \bl{NULL} & \onslide<3->{\ok}\\ |
|
471 |
\bl{der c (CHR d)} & \bl{$=$} & \bl{if c=d then EMPTY else NULL} & \onslide<3->{\ok}\\ |
|
472 |
\bl{der c (ALT r$_1$ r$_2$)} & \bl{$=$} & \bl{ALT (der c r$_1$) (der c r$_2$)} & \onslide<3->{\ok}\\ |
|
473 |
\bl{der c (SEQ r$_1$ r$_2$)} & \bl{$=$} & \bl{ALT (SEQ (der c r$_1$) r$_2$)} & \onslide<3->{\ok}\\ |
|
474 |
& & \bl{\phantom{ALT} (if nullable r$_1$ then der c r$_2$ else NULL)}\\ |
|
475 |
\bl{der c (STAR r)} & \bl{$=$} & \bl{SEQ (der c r) (STAR r)} & \onslide<3->{\ok}\medskip\\ |
|
476 |
\pause |
|
477 |
||
478 |
\bl{derivative r []} & \bl{$=$} & \bl{r} & \onslide<3->{\ok}\\ |
|
479 |
\bl{derivative r (c::s)} & \bl{$=$} & \bl{derivative (der c r) s} & \onslide<3->{\ok}\\ |
|
480 |
\end{tabular} |
|
481 |
\end{center} |
|
482 |
||
483 |
we call the program with\\ |
|
484 |
\bl{matches r s $=$ nullable (derivative r s)} |
|
485 |
||
486 |
||
487 |
\end{frame}} |
|
488 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
489 |
*} |
|
490 |
||
491 |
text_raw {* |
|
492 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
493 |
\mode<presentation>{ |
|
494 |
\begin{frame}<1->[c] |
|
495 |
\frametitle{But Now What?} |
|
496 |
||
497 |
\begin{center} |
|
498 |
{\usefont{T1}{ptm}{b}{N}\VERYHuge{\rd{?}}} |
|
499 |
\end{center} |
|
500 |
||
501 |
\end{frame}} |
|
502 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
503 |
*} |
|
504 |
||
505 |
text_raw {* |
|
506 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
507 |
\mode<presentation>{ |
|
508 |
\begin{frame}<1->[c] |
|
509 |
\frametitle{Testing} |
|
510 |
||
511 |
\small |
|
512 |
||
513 |
\begin{center} |
|
514 |
\begin{tabular}{@ {\hspace{-20mm}}lcl} |
|
515 |
\bl{matches []$^*$ []} & \bl{$\mapsto$} & \bl{true}\\ |
|
516 |
\bl{matches ([]$|$a)$^*$ a} & \bl{$\mapsto$} & \bl{true}\medskip\\ |
|
517 |
||
518 |
\bl{matches (a$\cdot$b)$^*\;$ []} & \bl{$\mapsto$} & \bl{true}\\ |
|
519 |
\bl{matches (a$\cdot$b)$^*\;$ ab} & \bl{$\mapsto$} & \bl{true}\\ |
|
520 |
\bl{matches (a$\cdot$b)$^*\;$ aba} & \bl{$\mapsto$} & \bl{false}\\ |
|
521 |
\bl{matches (a$\cdot$b)$^*\;$ abab} & \bl{$\mapsto$} & \bl{true}\\ |
|
522 |
\bl{matches (a$\cdot$b)$^*\;$ abaa} & \bl{$\mapsto$} & \bl{false}\medskip\\ |
|
523 |
||
524 |
\bl{matches x$\cdot$(0$|$1)$^*\;$ x} & \bl{$\mapsto$} & \bl{true}\\ |
|
525 |
\bl{matches x$\cdot$(0$|$1)$^*\;$ x0} & \bl{$\mapsto$} & \bl{true}\\ |
|
526 |
\bl{matches x$\cdot$(0$|$1)$^*\;$ x3} & \bl{$\mapsto$} & \bl{false} |
|
527 |
\end{tabular} |
|
528 |
\end{center} |
|
529 |
||
530 |
||
531 |
\end{frame}} |
|
532 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
533 |
*} |
|
534 |
||
535 |
text_raw {* |
|
536 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
537 |
\mode<presentation>{ |
|
538 |
\begin{frame}<1->[t] |
|
539 |
\frametitle{Specification} |
|
540 |
||
541 |
We have to specify what it means for a regular expression to match |
|
542 |
a string. |
|
543 |
% |
|
544 |
\only<2>{ |
|
545 |
\mbox{}\\[8mm] |
|
546 |
\bl{(a$\cdot$b)$^*$}\\ |
|
547 |
\hspace{7mm}\bl{$\mapsto$\hspace{3mm}\{[], ab, abab, ababab, \ldots\}}\bigskip\\ |
|
548 |
\bl{x$\cdot$(0 $|$ 1 $|$ 2 \ldots 8 $|$ 9 )$^*$}\\ |
|
549 |
\hspace{7mm}\bl{$\mapsto$\hspace{3mm} |
|
550 |
\{x, x0, x1, \ldots, x00, \ldots, x123, \ldots\}}} |
|
551 |
% |
|
552 |
\only<3->{ |
|
553 |
\begin{center} |
|
554 |
\begin{tabular}{rcl} |
|
555 |
\bl{\LL (NULL)} & \bl{$\dn$} & \bl{\{\}}\\ |
|
556 |
\bl{\LL (EMPTY)} & \bl{$\dn$} & \bl{\{[]\}}\\ |
|
557 |
\bl{\LL (CHR c)} & \bl{$\dn$} & \bl{\{c\}}\\ |
|
558 |
\bl{\LL (ALT r$_1$ r$_2$)} & \bl{$\dn$} & \onslide<4->{\bl{\LL (r$_1$) $\cup$ \LL (r$_2$)}}\\ |
|
559 |
\bl{\LL (SEQ r$_1$ r$_2$)} & \bl{$\dn$} & \onslide<6->{\bl{\LL (r$_1$) ; \LL (r$_2$)}}\\ |
|
560 |
\bl{\LL (STAR r)} & \bl{$\dn$} & \onslide<8->{\bl{(\LL (r))$^\star$}}\\ |
|
561 |
\end{tabular} |
|
562 |
\end{center}} |
|
563 |
||
564 |
\only<5-6>{ |
|
565 |
\begin{textblock}{6}(2.9,13.3) |
|
566 |
\colorbox{cream}{\bl{S$_1$ ; S$_2$ $\;\dn\;$ \{ s$_1$@s$_2$ $|$ s$_1$$\in$S$_1$ $\wedge$ |
|
567 |
s$_2$$\in$S$_2$ \}}} |
|
568 |
\end{textblock}} |
|
569 |
||
570 |
\only<7->{ |
|
571 |
\begin{textblock}{9}(4,13) |
|
572 |
\colorbox{cream}{\bl{$\infer{\mbox{[]} \in \mbox{S}^\star}{}$}}\hspace{3mm} |
|
573 |
\colorbox{cream}{\bl{$\infer{\mbox{s}_1\mbox{@}\mbox{s}_2 \in \mbox{S}^\star} |
|
574 |
{\mbox{s}_1 \in \mbox{S} & \mbox{s}_2 \in \mbox{S}^\star}$}} |
|
575 |
\end{textblock}} |
|
576 |
||
577 |
\end{frame}} |
|
578 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
579 |
*} |
|
580 |
||
581 |
text_raw {* |
|
582 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
583 |
\mode<presentation>{ |
|
584 |
\begin{frame}<1->[t] |
|
585 |
\frametitle{Is the Matcher Error-Free?} |
|
586 |
||
587 |
We expect that |
|
588 |
||
589 |
\begin{center} |
|
590 |
\begin{tabular}{lcl} |
|
591 |
\bl{matches r s = true} & \only<1>{\rd{$\Longrightarrow\,\,$}}\only<2>{\rd{$\Longleftarrow\,\,$}}% |
|
592 |
\only<3->{\rd{$\Longleftrightarrow$}} & \bl{s $\in$ \LL(r)}\\ |
|
593 |
\bl{matches r s = false} & \only<1>{\rd{$\Longrightarrow\,\,$}}\only<2>{\rd{$\Longleftarrow\,\,$}}% |
|
594 |
\only<3->{\rd{$\Longleftrightarrow$}} & \bl{s $\notin$ \LL(r)}\\ |
|
595 |
\end{tabular} |
|
596 |
\end{center} |
|
597 |
\pause\pause\bigskip |
|
598 |
By \alert<4->{induction}, we can {\bf prove} these properties.\bigskip |
|
599 |
||
600 |
\begin{tabular}{lrcl} |
|
601 |
Lemmas: & \bl{nullable (r)} & \bl{$\Longleftrightarrow$} & \bl{[] $\in$ \LL (r)}\\ |
|
602 |
& \bl{s $\in$ \LL (der c r)} & \bl{$\Longleftrightarrow$} & \bl{(c::s) $\in$ \LL (r)}\\ |
|
603 |
\end{tabular} |
|
604 |
||
605 |
\only<4->{ |
|
606 |
\begin{textblock}{3}(0.9,4.5) |
|
607 |
\rd{\huge$\forall$\large{}r s.} |
|
608 |
\end{textblock}} |
|
609 |
\end{frame}} |
|
610 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
611 |
*} |
|
612 |
||
613 |
text_raw {* |
|
614 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
615 |
\mode<presentation>{ |
|
616 |
\begin{frame}<1->[t] |
|
617 |
||
618 |
\mbox{}\\[-2mm] |
|
619 |
||
620 |
\small |
|
621 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}ll@ {}} |
|
622 |
\bl{nullable (NULL)} & \bl{$=$} & \bl{false} &\\ |
|
623 |
\bl{nullable (EMPTY)} & \bl{$=$} & \bl{true} &\\ |
|
624 |
\bl{nullable (CHR c)} & \bl{$=$} & \bl{false} &\\ |
|
625 |
\bl{nullable (ALT r$_1$ r$_2$)} & \bl{$=$} & \bl{(nullable r$_1$) orelse (nullable r$_2$)} & \\ |
|
626 |
\bl{nullable (SEQ r$_1$ r$_2$)} & \bl{$=$} & \bl{(nullable r$_1$) andalso (nullable r$_2$)} & \\ |
|
627 |
\bl{nullable (STAR r)} & \bl{$=$} & \bl{true} & \\ |
|
628 |
\end{tabular}\medskip |
|
629 |
||
630 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {\hspace{-10mm}}l@ {}} |
|
631 |
\bl{der c (NULL)} & \bl{$=$} & \bl{NULL} & \\ |
|
632 |
\bl{der c (EMPTY)} & \bl{$=$} & \bl{NULL} & \\ |
|
633 |
\bl{der c (CHR d)} & \bl{$=$} & \bl{if c=d then EMPTY else NULL} & \\ |
|
634 |
\bl{der c (ALT r$_1$ r$_2$)} & \bl{$=$} & \bl{ALT (der c r$_1$) (der c r$_2$)} & \\ |
|
635 |
\bl{der c (SEQ r$_1$ r$_2$)} & \bl{$=$} & \bl{ALT (SEQ (der c r$_1$) r$_2$)} & \\ |
|
636 |
& & \bl{\phantom{ALT} (if nullable r$_1$ then der c r$_2$ else NULL)}\\ |
|
637 |
\bl{der c (STAR r)} & \bl{$=$} & \bl{SEQ (der c r) (STAR r)} &\smallskip\\ |
|
638 |
||
639 |
\bl{derivative r []} & \bl{$=$} & \bl{r} & \\ |
|
640 |
\bl{derivative r (c::s)} & \bl{$=$} & \bl{derivative (der c r) s} & \\ |
|
641 |
\end{tabular}\medskip |
|
642 |
||
643 |
\bl{matches r s $=$ nullable (derivative r s)} |
|
644 |
||
645 |
\only<2>{ |
|
646 |
\begin{textblock}{8}(1.5,4) |
|
647 |
\includegraphics[scale=0.3]{approved.png} |
|
648 |
\end{textblock}} |
|
649 |
||
650 |
||
651 |
\end{frame}} |
|
652 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
653 |
*} |
|
654 |
||
655 |
||
656 |
text_raw {* |
|
657 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
658 |
\mode<presentation>{ |
|
659 |
\begin{frame}<1->[c] |
|
660 |
\frametitle{Interlude: TCB} |
|
661 |
||
662 |
\begin{itemize} |
|
663 |
\item The \alert{\bf Trusted Code Base} (TCB) is the code that can make your |
|
664 |
program behave in unintended ways (i.e.~cause bugs).\medskip |
|
665 |
||
666 |
\item Typically the TCB includes: CPUs, operating systems, C-libraries, |
|
667 |
device drivers, (J)VMs\ldots\bigskip |
|
668 |
\pause |
|
669 |
||
670 |
\item It also includes the compiler. |
|
671 |
\end{itemize} |
|
672 |
||
673 |
\end{frame}} |
|
674 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
675 |
*} |
|
676 |
||
677 |
text_raw {* |
|
678 |
||
679 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
680 |
\mode<presentation>{ |
|
681 |
\begin{frame}<1-3> |
|
682 |
\frametitle{\LARGE\begin{tabular}{c}Hacking Compilers |
|
683 |
\end{tabular}} |
|
684 |
||
685 |
%Why is it so paramount to have a small trusted code base (TCB)? |
|
686 |
\bigskip\bigskip |
|
687 |
||
688 |
\begin{columns} |
|
689 |
\begin{column}{2.7cm} |
|
690 |
\begin{minipage}{2.5cm}% |
|
691 |
\begin{tabular}{c@ {}} |
|
692 |
\includegraphics[scale=0.2]{ken-thompson.jpg}\\[-1.8mm] |
|
693 |
\footnotesize Ken Thompson\\[-1.8mm] |
|
694 |
\footnotesize Turing Award, 1983\\ |
|
695 |
\end{tabular} |
|
696 |
\end{minipage} |
|
697 |
\end{column} |
|
698 |
\begin{column}{9cm} |
|
699 |
\begin{tabular}{l@ {\hspace{1mm}}p{8cm}} |
|
700 |
\myitemi |
|
701 |
& Ken Thompson showed how to hide a Trojan Horse in a |
|
702 |
compiler \textcolor{red}{without} leaving any traces in the source code.\\[2mm] |
|
703 |
\myitemi |
|
704 |
& No amount of source level verification will protect |
|
705 |
you from such Thompson-hacks.\\[2mm] |
|
706 |
||
707 |
\myitemi |
|
708 |
& Therefore in safety-critical systems it is important to rely |
|
709 |
on only a very small TCB. |
|
710 |
\end{tabular} |
|
711 |
\end{column} |
|
712 |
\end{columns} |
|
713 |
||
714 |
\only<2>{ |
|
715 |
\begin{textblock}{6}(4,2) |
|
716 |
\begin{tikzpicture} |
|
717 |
\draw (0,0) node[inner sep=3mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
|
718 |
{\normalsize |
|
719 |
\begin{minipage}{8cm} |
|
720 |
\begin{quote} |
|
721 |
\includegraphics[scale=0.05]{evil.png} |
|
722 |
\begin{enumerate} |
|
723 |
\item[1)] Assume you ship the compiler as binary and also with sources. |
|
724 |
\item[2)] Make the compiler aware when it compiles itself. |
|
725 |
\item[3)] Add the Trojan horse. |
|
726 |
\item[4)] Compile. |
|
727 |
\item[5)] Delete Trojan horse from the sources of the compiler. |
|
728 |
\item[6)] Go on holiday for the rest of your life. ;o)\\[-7mm]\mbox{} |
|
729 |
\end{enumerate} |
|
730 |
\end{quote} |
|
731 |
\end{minipage}}; |
|
732 |
\end{tikzpicture} |
|
733 |
\end{textblock}} |
|
734 |
||
735 |
\end{frame}} |
|
736 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
737 |
||
738 |
*} |
|
739 |
||
740 |
text_raw {* |
|
741 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
742 |
\mode<presentation>{ |
|
743 |
\begin{frame} |
|
744 |
\frametitle{\LARGE\begin{tabular}{c}An Example: Small TCB for\\[-2mm] |
|
745 |
A Critical Infrastructure\end{tabular}} |
|
746 |
\mbox{}\\[-14mm]\mbox{} |
|
747 |
||
748 |
\begin{columns} |
|
749 |
\begin{column}{0.2\textwidth} |
|
750 |
\begin{tabular}{@ {} c@ {}} |
|
751 |
\includegraphics[scale=0.3]{appel.jpg}\\[-2mm] |
|
752 |
{\footnotesize Andrew Appel}\\[-2.5mm] |
|
753 |
{\footnotesize (Princeton)} |
|
754 |
\end{tabular} |
|
755 |
\end{column} |
|
756 |
||
757 |
\begin{column}{0.8\textwidth} |
|
758 |
\begin{textblock}{10}(4.5,3.95) |
|
759 |
\begin{block}{Proof-Carrying Code} |
|
760 |
\begin{center} |
|
761 |
\begin{tikzpicture} |
|
762 |
\draw[help lines,cream] (0,0.2) grid (8,4); |
|
763 |
||
764 |
\draw[line width=1mm, red] (5.5,0.6) rectangle (7.5,4); |
|
765 |
\node[anchor=base] at (6.5,2.8) |
|
766 |
{\small\begin{tabular}{@ {}p{1.9cm}@ {}}\centering user needs to run untrusted code\end{tabular}}; |
|
767 |
||
768 |
\draw[line width=1mm, red] (0.5,0.6) rectangle (2.5,4); |
|
769 |
\node[anchor=base] at (1.5,2.3) |
|
770 |
{\small\begin{tabular}{@ {}p{1.9cm}@ {}}\centering code developer/ web server/ Apple |
|
771 |
Store\end{tabular}}; |
|
772 |
||
773 |
\onslide<4->{ |
|
774 |
\draw[line width=1mm, red, fill=red] (5.5,0.6) rectangle (7.5,1.8); |
|
775 |
\node[anchor=base,white] at (6.5,1.1) |
|
776 |
{\small\begin{tabular}{@ {}p{1.9cm}@ {}}\bf\centering proof- checker\end{tabular}};} |
|
777 |
||
778 |
\node at (3.8,3.0) [single arrow, fill=red,text=white, minimum height=3cm]{\bf code}; |
|
779 |
\onslide<3->{ |
|
780 |
\node at (3.8,1.3) [single arrow, fill=red,text=white, minimum height=3cm]{\bf LF proof}; |
|
781 |
\node at (3.8,1.9) {\small certificate}; |
|
782 |
} |
|
783 |
||
784 |
\onslide<2>{\node at (4.0,1.3) [text=red]{\begin{tabular}{c}\bf Highly\\\bf Dangerous!\end{tabular}};} |
|
785 |
% Code Developer |
|
786 |
% User (runs untrusted code) |
|
787 |
% transmits a proof that the code is safe |
|
788 |
% |
|
789 |
\end{tikzpicture} |
|
790 |
\end{center} |
|
791 |
\end{block} |
|
792 |
\end{textblock} |
|
793 |
\end{column} |
|
794 |
\end{columns} |
|
795 |
||
796 |
\small\mbox{}\\[2.5cm] |
|
797 |
\begin{itemize} |
|
798 |
\item<4-> TCB of the checker is $\sim$2700 lines of code (1865 loc of\\ LF definitions; |
|
799 |
803 loc in C including 2 library functions)\\[-3mm] |
|
800 |
\item<5-> 167 loc in C implement a type-checker |
|
801 |
\end{itemize} |
|
802 |
||
803 |
\end{frame}} |
|
804 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
805 |
||
806 |
*} |
|
807 |
||
808 |
||
809 |
||
810 |
text {* |
|
811 |
\tikzstyle{every node}=[node distance=25mm,text height=1.5ex, text depth=.25ex] |
|
812 |
\tikzstyle{node1}=[rectangle, minimum size=10mm, rounded corners=3mm, very thick, |
|
813 |
draw=black!50, top color=white, bottom color=black!20] |
|
814 |
\tikzstyle{node2}=[rectangle, minimum size=12mm, rounded corners=3mm, very thick, |
|
815 |
draw=red!70, top color=white, bottom color=red!50!black!20] |
|
816 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
817 |
\mode<presentation>{ |
|
818 |
\begin{frame}[squeeze] |
|
819 |
\frametitle{Type-Checking in LF} |
|
820 |
||
821 |
\begin{columns} |
|
822 |
\begin{column}{0.2\textwidth} |
|
823 |
\begin{tabular}{@ {\hspace{-4mm}}c@ {}} |
|
824 |
\\[-4mm] |
|
825 |
\includegraphics[scale=0.1]{harper.jpg}\\[-2mm] |
|
826 |
{\footnotesize Bob Harper}\\[-2.5mm] |
|
827 |
{\footnotesize (CMU)}\\[2mm] |
|
828 |
||
829 |
\includegraphics[scale=0.3]{pfenning.jpg}\\[-2mm] |
|
830 |
{\footnotesize Frank Pfenning}\\[-2.5mm] |
|
831 |
{\footnotesize (CMU)}\\[2mm] |
|
832 |
||
833 |
\onslide<-6>{ |
|
834 |
{\footnotesize 31 pages in }\\[-2.5mm] |
|
835 |
{\footnotesize ACM Transact.~on}\\[-2.5mm] |
|
836 |
{\footnotesize Comp.~Logic.,~2005}\\} |
|
837 |
\end{tabular} |
|
838 |
\end{column} |
|
839 |
||
840 |
\begin{column}{0.8\textwidth} |
|
841 |
\begin{textblock}{0}(3.1,2) |
|
842 |
||
843 |
\begin{tikzpicture} |
|
844 |
\matrix[ampersand replacement=\&,column sep=7mm, row sep=5mm] |
|
845 |
{ \&[-10mm] |
|
846 |
\node (def1) [node1] {\large\hspace{1mm}Spec\hspace{1mm}\mbox{}}; \& |
|
847 |
\node (proof1) [node1] {\large Proof}; \& |
|
848 |
\node (alg1) [node1] {\large\hspace{1mm}Alg\hspace{1mm}\mbox{}}; \\ |
|
849 |
||
850 |
\onslide<4->{\node {\begin{tabular}{c}\small 1st\\[-2.5mm] \footnotesize solution\end{tabular}};} \& |
|
851 |
\onslide<4->{\node (def2) [node2] {\large Spec$^\text{+ex}$};} \& |
|
852 |
\onslide<4->{\node (proof2) [node1] {\large Proof};} \& |
|
853 |
\onslide<4->{\node (alg2) [node1] {\large\hspace{1mm}Alg\hspace{1mm}\mbox{}};} \\ |
|
854 |
||
855 |
\onslide<5->{\node {\begin{tabular}{c}\small 2nd\\[-2.5mm] \footnotesize solution\end{tabular}};} \& |
|
856 |
\onslide<5->{\node (def3) [node1] {\large\hspace{1mm}Spec\hspace{1mm}\mbox{}};} \& |
|
857 |
\onslide<5->{\node (proof3) [node1] {\large Proof};} \& |
|
858 |
\onslide<5->{\node (alg3) [node2] {\large Alg$^\text{-ex}$};} \\ |
|
859 |
||
860 |
\onslide<6->{\node {\begin{tabular}{c}\small 3rd\\[-2.5mm] \footnotesize solution\end{tabular}};} \& |
|
861 |
\onslide<6->{\node (def4) [node1] {\large\hspace{1mm}Spec\hspace{1mm}\mbox{}};} \& |
|
862 |
\onslide<6->{\node (proof4) [node2] {\large\hspace{1mm}Proof\hspace{1mm}};} \& |
|
863 |
\onslide<6->{\node (alg4) [node1] {\large\hspace{1mm}Alg\hspace{1mm}\mbox{}};} \\ |
|
864 |
}; |
|
865 |
||
866 |
\draw[->,black!50,line width=2mm] (proof1) -- (def1); |
|
867 |
\draw[->,black!50,line width=2mm] (proof1) -- (alg1); |
|
868 |
||
869 |
\onslide<4->{\draw[->,black!50,line width=2mm] (proof2) -- (def2);} |
|
870 |
\onslide<4->{\draw[->,black!50,line width=2mm] (proof2) -- (alg2);} |
|
871 |
||
872 |
\onslide<5->{\draw[->,black!50,line width=2mm] (proof3) -- (def3);} |
|
873 |
\onslide<5->{\draw[->,black!50,line width=2mm] (proof3) -- (alg3);} |
|
874 |
||
875 |
\onslide<6->{\draw[->,black!50,line width=2mm] (proof4) -- (def4);} |
|
876 |
\onslide<6->{\draw[->,black!50,line width=2mm] (proof4) -- (alg4);} |
|
877 |
||
878 |
\onslide<3->{\draw[white,line width=1mm] (1.1,3.2) -- (0.9,2.85) -- (1.1,2.35) -- (0.9,2.0);} |
|
879 |
\end{tikzpicture} |
|
880 |
||
881 |
\end{textblock} |
|
882 |
\end{column} |
|
883 |
\end{columns} |
|
884 |
||
885 |
\only<2>{% |
|
886 |
\begin{textblock}{2}(.1,12.85) |
|
887 |
\begin{tikzpicture} |
|
888 |
\draw[line width=1mm, red] (0,0) ellipse (1.5cm and 0.88cm); |
|
889 |
\end{tikzpicture} |
|
890 |
\end{textblock} |
|
891 |
} |
|
892 |
||
893 |
\begin{textblock}{3}(14,3.6) |
|
894 |
\onslide<4->{ |
|
895 |
\begin{tikzpicture} |
|
896 |
\node at (0,0) [single arrow, shape border rotate=270, fill=red,text=white]{2h}; |
|
897 |
\end{tikzpicture}} |
|
898 |
\end{textblock} |
|
899 |
||
900 |
\only<7->{ |
|
901 |
\begin{textblock}{14}(0.6,12.8) |
|
902 |
\begin{block}{} |
|
903 |
\small Each time one needs to check $\sim$31pp~of informal paper proofs. |
|
904 |
You have to be able to keep definitions and proofs consistent. |
|
905 |
\end{block} |
|
906 |
\end{textblock}} |
|
907 |
||
908 |
\end{frame}} |
|
909 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
910 |
||
911 |
*} |
|
912 |
||
913 |
text_raw {* |
|
914 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
915 |
\mode<presentation>{ |
|
916 |
\begin{frame}<1>[c] |
|
917 |
\frametitle{Theorem Provers} |
|
918 |
||
919 |
\begin{itemize} |
|
920 |
\item Theorem provers help with keeping large proofs consistent; |
|
921 |
make them modifiable.\medskip |
|
922 |
||
923 |
\item They can ensure that all cases are covered.\medskip |
|
924 |
||
925 |
\item Sometimes, tedious reasoning can be automated. |
|
926 |
\end{itemize} |
|
927 |
||
928 |
\end{frame}} |
|
929 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
930 |
*} |
|
931 |
||
932 |
text_raw {* |
|
933 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
934 |
\mode<presentation>{ |
|
935 |
\begin{frame}<1>[c] |
|
936 |
\frametitle{Theorem Provers} |
|
937 |
||
938 |
\begin{itemize} |
|
939 |
\item You also pay a (sometimes heavy) price: reasoning can be much, much harder.\medskip |
|
940 |
||
941 |
\item Depending on your domain, suitable reasoning infrastructure |
|
942 |
might not yet be available. |
|
943 |
\end{itemize} |
|
944 |
||
945 |
\end{frame}} |
|
946 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
947 |
*} |
|
948 |
||
949 |
text_raw {* |
|
950 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
951 |
\mode<presentation>{ |
|
952 |
\begin{frame}<1>[c] |
|
953 |
\frametitle{Theorem Provers} |
|
954 |
||
955 |
Recently impressive work has been accomplished proving the correctness |
|
956 |
||
957 |
\begin{itemize} |
|
958 |
\item of a compiler for C-light (compiled code has the same observable |
|
959 |
behaviour as the original source code),\medskip |
|
960 |
||
961 |
\item a mirco-kernel operating system (absence of certain |
|
962 |
bugs\ldots no nil pointers, no buffer overflows). |
|
963 |
\end{itemize} |
|
964 |
||
965 |
\end{frame}} |
|
966 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
967 |
*} |
|
968 |
||
969 |
||
970 |
text_raw {* |
|
971 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
972 |
\mode<presentation>{ |
|
973 |
\begin{frame}<1>[c] |
|
974 |
\frametitle{Trust in Theorem Provers} |
|
975 |
||
976 |
\begin{center} |
|
977 |
Why should we trust theorem provers? |
|
978 |
\end{center} |
|
979 |
||
980 |
\end{frame}} |
|
981 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
982 |
*} |
|
983 |
||
984 |
text_raw {* |
|
985 |
||
986 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
987 |
\mode<presentation>{ |
|
988 |
\begin{frame} |
|
989 |
\frametitle{Theorem Provers} |
|
990 |
||
991 |
\begin{itemize} |
|
992 |
\item Theorem provers are a \textcolor{red}{special kind} of software. |
|
993 |
||
994 |
\item We do \textcolor{red}{\bf not} need to trust them; we only need to trust: |
|
995 |
\end{itemize} |
|
996 |
||
997 |
\begin{quote} |
|
998 |
\begin{itemize} |
|
999 |
\item The logic they are based on \textcolor{gray}{(e.g.~HOL)}, and\smallskip |
|
1000 |
\item a proof checker that checks the proofs |
|
1001 |
\textcolor{gray}{(this can be a very small program)}.\smallskip\pause |
|
1002 |
\item To a little extend, we also need to trust our definitions |
|
1003 |
\textcolor{gray}{(this can be mitigated)}. |
|
1004 |
\end{itemize} |
|
1005 |
\end{quote} |
|
1006 |
||
1007 |
\end{frame}} |
|
1008 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1009 |
||
1010 |
*} |
|
1011 |
||
1012 |
text_raw {* |
|
1013 |
||
1014 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1015 |
\mode<presentation>{ |
|
1016 |
\begin{frame} |
|
1017 |
\frametitle{Isabelle} |
|
1018 |
||
1019 |
\begin{itemize} |
|
1020 |
\item I am using the Isabelle theorem prover (development since 1990).\bigskip\bigskip\bigskip |
|
1021 |
||
1022 |
\item It follows the LCF-approach: |
|
1023 |
||
1024 |
\begin{itemize} |
|
1025 |
\item Have a special abstract type \alert{\bf thm}. |
|
1026 |
\item Make the constructors of this abstract type the inference rules |
|
1027 |
of your logic. |
|
1028 |
\item Implement the theorem prover in a strongly-typed language (e.g.~ML). |
|
1029 |
\end{itemize} |
|
1030 |
||
1031 |
$\Rightarrow$ everything of type {\bf thm} has been proved (even if we do not |
|
1032 |
have to explicitly generate proofs). |
|
1033 |
\end{itemize} |
|
1034 |
||
1035 |
\only<1>{ |
|
1036 |
\begin{textblock}{5}(11,2.3) |
|
1037 |
\begin{center} |
|
1038 |
\includegraphics[scale=0.18]{robin-milner.jpg}\\[-0.8mm] |
|
1039 |
\footnotesize Robin Milner\\[-0.8mm] |
|
1040 |
\footnotesize Turing Award, 1991\\ |
|
1041 |
\end{center} |
|
1042 |
\end{textblock}} |
|
1043 |
||
1044 |
||
1045 |
\end{frame}} |
|
1046 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1047 |
*} |
|
1048 |
||
1049 |
text_raw {* |
|
1050 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1051 |
\mode<presentation>{ |
|
1052 |
\begin{frame}<1>[c] |
|
1053 |
\frametitle{ |
|
1054 |
\begin{tabular}{c} |
|
1055 |
\mbox{}\\[23mm] |
|
1056 |
\LARGE Demo |
|
1057 |
\end{tabular}} |
|
1058 |
||
1059 |
\end{frame}} |
|
1060 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1061 |
*} |
|
1062 |
||
1063 |
||
1064 |
text_raw {* |
|
1065 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1066 |
\mode<presentation>{ |
|
1067 |
\begin{frame}<1->[c] |
|
1068 |
\frametitle{Future Research} |
|
1069 |
||
1070 |
\begin{itemize} |
|
1071 |
\item Make theorem provers more like a programming environment.\medskip\pause |
|
1072 |
||
1073 |
\item Use all the computational power we get from the hardware to |
|
1074 |
automate reasoning (GPUs).\medskip\pause |
|
1075 |
||
1076 |
\item Provide a comprehensive reasoning infrastructure for many domains and |
|
1077 |
design automated decision procedures. |
|
1078 |
\end{itemize}\pause |
|
1079 |
||
1080 |
||
1081 |
\begin{center} |
|
1082 |
\colorbox{cream}{ |
|
1083 |
\begin{minipage}{10cm} |
|
1084 |
\color{gray} |
|
1085 |
\small |
|
1086 |
``Formal methods will never have a significant impact until |
|
1087 |
they can be used by people that don't understand them.''\smallskip\\ |
|
1088 |
\mbox{}\footnotesize\hfill attributed to Tom Melham |
|
1089 |
\end{minipage}} |
|
1090 |
\end{center} |
|
1091 |
||
1092 |
\end{frame}} |
|
1093 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1094 |
*} |
|
1095 |
||
1096 |
text_raw {* |
|
1097 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1098 |
\mode<presentation>{ |
|
1099 |
\begin{frame}<1->[c] |
|
1100 |
\frametitle{Conclusion} |
|
1101 |
||
1102 |
\begin{itemize} |
|
1103 |
\item The plan is to make this kind of programming the ``future''.\medskip\pause |
|
1104 |
||
1105 |
\item Though the technology is already there\\ (compiler + micro-kernel os).\medskip\pause |
|
1106 |
||
1107 |
\item Logic and reasoning (especially induction) are important skills for |
|
1108 |
Computer Scientists. |
|
1109 |
\end{itemize} |
|
1110 |
||
1111 |
\end{frame}} |
|
1112 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1113 |
*} |
|
1114 |
||
1115 |
||
1116 |
text_raw {* |
|
1117 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1118 |
\mode<presentation>{ |
|
1119 |
\begin{frame}<1>[c] |
|
1120 |
\frametitle{ |
|
1121 |
\begin{tabular}{c} |
|
1122 |
\mbox{}\\[23mm] |
|
1123 |
\alert{\LARGE Thank you very much!}\\ |
|
1124 |
\alert{\Large Questions?} |
|
1125 |
\end{tabular}} |
|
1126 |
||
1127 |
\end{frame}} |
|
1128 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1129 |
*} |
|
1130 |
||
1131 |
||
1132 |
||
1133 |
(*<*) |
|
1134 |
end |
|
1135 |
(*>*) |