slides/slides09.tex
author Christian Urban <urbanc@in.tum.de>
Tue, 27 Nov 2018 00:45:26 +0000
changeset 609 e33545bb2eba
parent 538 17acdd516ccd
child 610 7ec1bdb670ba
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
65
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
\documentclass[dvipsnames,14pt,t]{beamer}
309
640e4a05cd9b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
     2
\usepackage{../slides}
215
828303e8e4af updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
     3
\usepackage{../langs}
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
     4
\usepackage{../data}
309
640e4a05cd9b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
     5
\usepackage{../graphics}
379
fa2589ec0fae updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 312
diff changeset
     6
\usepackage{../grammar}
310
d384fe01d0e8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 309
diff changeset
     7
\usepackage{soul}
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
     8
310
d384fe01d0e8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 309
diff changeset
     9
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    10
% beamer stuff
459
780486571e38 updated
Christian Urban <urbanc@in.tum.de>
parents: 384
diff changeset
    11
\renewcommand{\slidecaption}{CFL 09, King's College London}
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    12
\newcommand{\bl}[1]{\textcolor{blue}{#1}}       
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    13
310
d384fe01d0e8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 309
diff changeset
    14
65
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
\begin{document}
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    16
65
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309
640e4a05cd9b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    18
\begin{frame}[t]
65
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
\frametitle{%
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
  \begin{tabular}{@ {}c@ {}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
  \\[-3mm]
459
780486571e38 updated
Christian Urban <urbanc@in.tum.de>
parents: 384
diff changeset
    22
  \LARGE Compilers and \\[-2mm] 
538
17acdd516ccd updated
Christian Urban <urbanc@in.tum.de>
parents: 537
diff changeset
    23
  \LARGE Formal Languages (9)\\[3mm] 
65
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
  \end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
  \normalsize
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    27
  \begin{center}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
  \begin{tabular}{ll}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
  Email:  & christian.urban at kcl.ac.uk\\
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    30
  Office: & N\liningnums{7.07} (North Wing, Bush House)\\
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    31
  Slides: & KEATS (also homework is there)\\
538
17acdd516ccd updated
Christian Urban <urbanc@in.tum.de>
parents: 537
diff changeset
    32
  \end{tabular}
17acdd516ccd updated
Christian Urban <urbanc@in.tum.de>
parents: 537
diff changeset
    33
  \end{center}
310
d384fe01d0e8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 309
diff changeset
    34
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    35
\end{frame}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    36
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    37
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    38
 
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    39
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    40
\begin{frame}[t]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    41
\frametitle{While Language}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    42
  
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    43
\begin{center}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    44
\bl{\begin{tabular}{@{}lcl@{}}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    45
\\[-12mm]        
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    46
\meta{Stmt} & $::=$ &  $\texttt{skip}$\\
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    47
              & $|$ & \textit{Id}\;\texttt{:=}\;\meta{AExp}\\
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    48
              & $|$ & \texttt{if}\; \meta{BExp} \;\texttt{then}\; \meta{Block} \;\texttt{else}\; \meta{Block}\\
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    49
              & $|$ & \texttt{while}\; \meta{BExp} \;\texttt{do}\; \meta{Block}\\
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    50
              & $|$ & \texttt{read}\;\textit{Id}\\
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    51
              & $|$ & \texttt{write}\;\textit{Id}\\
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    52
              & $|$ & \texttt{write}\;\textit{String}\medskip\\
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    53
\meta{Stmts} & $::=$ &  \meta{Stmt} \;\texttt{;}\; \meta{Stmts} $|$  \meta{Stmt}\medskip\\
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    54
\meta{Block} & $::=$ &  \texttt{\{}\,\meta{Stmts}\,\texttt{\}} $|$ \meta{Stmt}\medskip\\
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    55
\meta{AExp} & $::=$ & \ldots\\
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    56
\meta{BExp} & $::=$ & \ldots\\
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    57
\end{tabular}}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    58
\end{center}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    59
\end{frame}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    60
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    61
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    62
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    63
\begin{frame}[c]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    64
\frametitle{\begin{tabular}{c}Fibonacci Numbers\end{tabular}}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    65
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    66
\mbox{}\\[-18mm]\mbox{}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    67
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    68
{\lstset{language=While}\fontsize{10}{12}\selectfont
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    69
\texttt{\lstinputlisting{../progs/fib.while}}}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    70
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    71
\end{frame}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    72
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    73
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    74
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    75
\begin{frame}[c,fragile]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    76
\frametitle{BF***}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    77
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    78
some big array, say \texttt{a}; 7 (8) instructions:
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    79
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    80
\begin{itemize}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    81
\item \texttt{>} move \texttt{ptr++}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    82
\item \texttt{<} move \texttt{ptr-{}-}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    83
\item \texttt{+} add \texttt{a[ptr]++}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    84
\item \texttt{-} subtract \texttt{a[ptr]-{}-}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    85
\item \texttt{.} print out \texttt{a[ptr]} as ASCII
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    86
\item \texttt{[} if \texttt{a[ptr] == 0} jump just after the corresponding \texttt{]}; otherwise \texttt{ptr++}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    87
\item \texttt{]} if \texttt{a[ptr] != 0} jump just after the corresponding \texttt{[}; otherwise \texttt{ptr++}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    88
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    89
\end{itemize}  
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    90
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    91
\end{frame}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    92
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    93
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    94
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    95
\begin{frame}[c,fragile]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    96
\frametitle{Arrays in While}
310
d384fe01d0e8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 309
diff changeset
    97
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    98
\begin{itemize}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
    99
\item \texttt{new arr[15000]}\medskip 
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   100
\item \texttt{x := 3 + arr[3 + y]}\medskip 
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   101
\item \texttt{arr[42 * n] := ...}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   102
\end{itemize}  
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   103
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   104
\end{frame}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   105
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   106
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   107
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   108
\begin{frame}[c,fragile]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   109
\frametitle{New Arrays}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   110
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   111
\begin{lstlisting}[mathescape,numbers=none,language=While]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   112
  new arr[number]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   113
\end{lstlisting}\bigskip\bigskip
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   114
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   115
\begin{lstlisting}[mathescape,numbers=none,language=While]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   116
  ldc number
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   117
  newarray int
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   118
  astore loc_var
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   119
\end{lstlisting}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   120
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   121
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   122
\end{frame}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   123
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   124
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   125
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   126
\begin{frame}[c,fragile]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   127
\frametitle{Array Update}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   128
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   129
\begin{lstlisting}[mathescape,numbers=none,language=While]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   130
  arr[...] := 
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   131
\end{lstlisting}\bigskip\bigskip
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   132
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   133
\begin{lstlisting}[mathescape,numbers=none,language=While]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   134
  aload loc_var
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   135
  index_aexp
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   136
  value_aexp
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   137
  iastore
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   138
\end{lstlisting}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   139
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   140
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   141
\end{frame}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   142
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   143
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   144
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   145
\begin{frame}[c,fragile]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   146
\frametitle{Array Lookup in AExp}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   147
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   148
\begin{lstlisting}[mathescape,numbers=none,language=While]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   149
  ...arr[...]... 
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   150
\end{lstlisting}\bigskip\bigskip
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   151
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   152
\begin{lstlisting}[mathescape,numbers=none,language=While]
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   153
  aload loc_var
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   154
  index_aexp
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   155
  iaload
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   156
\end{lstlisting}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   157
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   158
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   159
\end{frame}
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   160
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
310
d384fe01d0e8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 309
diff changeset
   161
d384fe01d0e8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 309
diff changeset
   162
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   163
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   164
  \begin{frame}[c]
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   165
  \frametitle{Dijkstra on Testing}
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   166
  
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   167
  \begin{bubble}[10cm]
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   168
  ``Program testing can be a very effective way to show the
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   169
  presence of bugs, but it is hopelessly inadequate for showing
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   170
  their absence.''
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   171
  \end{bubble}\bigskip
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   172
  
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   173
  \small
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   174
  What is good about compilers: the either seem to work,
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   175
  or go horribly wrong (most of the time).
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   176
  
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   177
  \end{frame}
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   178
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   179
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   180
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   181
\begin{frame}[c]
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   182
\frametitle{\Large Proving Programs to be Correct}
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   183
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   184
\begin{bubble}[10cm]
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   185
\small
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   186
{\bf Theorem:} There are infinitely many prime 
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   187
numbers.\medskip\\
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   188
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   189
{\bf Proof} \ldots\\
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   190
\end{bubble}\bigskip
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   191
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   192
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   193
similarly\bigskip
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   194
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   195
\begin{bubble}[10cm]
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   196
\small
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   197
{\bf Theorem:} The program is doing what 
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   198
it is supposed to be doing.\medskip
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   199
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   200
{\bf Long, long proof} \ldots\\
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   201
\end{bubble}\bigskip\medskip
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   202
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   203
\small This can be a gigantic proof. The only hope is to have
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   204
help from the computer. `Program' is here to be understood to be
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   205
quite general (compiler, OS, \ldots).
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   206
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   207
\end{frame}
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   208
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   209
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   210
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   211
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   212
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   213
\begin{frame}[c]
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   214
\frametitle{Can This Be Done?}
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   215
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   216
\begin{itemize}
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   217
\item in 2008, verification of a small C-compiler
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   218
\begin{itemize}
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   219
\item ``if my input program has a certain behaviour, then the compiled machine code has the same behaviour''
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   220
\item is as good as \texttt{gcc -O1}, but much, much less buggy 
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   221
\end{itemize}
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   222
\end{itemize}
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   223
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   224
\begin{center}
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   225
  \includegraphics[scale=0.12]{../pics/compcert.png}
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   226
\end{center}
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   227
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   228
\end{frame}
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   229
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   230
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   231
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   232
\begin{frame}[c]
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   233
\frametitle{Fuzzy Testing C-Compilers}
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   234
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   235
\begin{itemize}
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   236
\item tested GCC, LLVM and others by randomly generating 
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   237
C-programs
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   238
\item found more than 300 bugs in GCC and also
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   239
many in LLVM (some of them highest-level critical)\bigskip
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   240
\item about CompCert:
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   241
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   242
\begin{bubble}[10cm]\small ``The striking thing about our CompCert
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   243
results is that the middle-end bugs we found in all other
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   244
compilers are absent. As of early 2011, the under-development
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   245
version of CompCert is the only compiler we have tested for
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   246
which Csmith cannot find wrong-code errors. This is not for
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   247
lack of trying: we have devoted about six CPU-years to the
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   248
task.'' 
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   249
\end{bubble} 
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   250
\end{itemize}
206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
   251
383
a6a6bf32fade updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   252
\end{frame}
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 538
diff changeset
   253
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
82
06c3ec0b452e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   254
65
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   255
\end{document}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   256
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   257
%%% Local Variables:  
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   258
%%% mode: latex
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   259
%%% TeX-master: t
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   260
%%% End: 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   261