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