slides/slides01.tex
author Christian Urban <christian.urban@kcl.ac.uk>
Thu, 29 Sep 2022 20:54:02 +0100
changeset 876 771396fa6cc4
parent 871 94b84d880c2b
child 879 ad9d4a01e072
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
876
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
     1
% !TEX program = xelatex
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
     2
\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
     3
\usepackage{../slides}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
     4
\usepackage{../graphicss}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
     5
\usepackage{../langs}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
     6
\usepackage{../data}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
     7
\usetikzlibrary{cd}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
     8
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
     9
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    10
\usepackage{tcolorbox}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    11
\newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    12
\newtcolorbox{mybox2}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    13
\newtcolorbox{mybox3}[1]{colback=Cyan!5!white,colframe=Cyan!75!black,fonttitle=\bfseries,title=#1}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    14
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    15
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    16
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    17
\hfuzz=220pt 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    18
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    19
\lstset{language=Scala,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    20
        style=mystyle,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    21
        numbersep=0pt,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    22
        numbers=none,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    23
        xleftmargin=0mm}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    24
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    25
\newcommand{\bl}[1]{\textcolor{blue}{#1}}     
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    26
 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    27
% beamer stuff 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    28
\renewcommand{\slidecaption}{CFL 01, King's College London}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    29
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    30
%% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect1/main.pdf
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    31
%% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect2/main.pdf
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    32
%% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect3/main.pdf
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    33
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    34
\begin{document}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    35
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    36
%\begin{frame}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    37
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    38
%\begin{mybox}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    39
%A physical explanation the \emph{dynamic matrix}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    40
%lots of text
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    41
%\end{mybox}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    42
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    43
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    44
%\begin{mybox2}{Test}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    45
%A physical explanation the \emph{dynamic matrix}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    46
%lots of text
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    47
%\end{mybox2}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    48
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    49
%\begin{mybox3}{Test}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    50
%A physical explanation the \emph{dynamic matrix}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    51
%lots of text
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    52
%\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    53
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    54
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    55
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    56
\begin{frame}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    57
\frametitle{%  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    58
  \begin{tabular}{@ {}c@ {}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    59
  \\[-3mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    60
  \LARGE Compilers and \\[-1mm] 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    61
  \LARGE Formal Languages\\[-3mm] 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    62
  \end{tabular}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    63
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    64
  \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    65
  %\includegraphics[scale=0.3]{pics/ante1.jpg}\hspace{5mm}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    66
  %\includegraphics[scale=0.31]{pics/ante2.jpg}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    67
  %\footnotesize\textcolor{gray}{Antikythera automaton, 100 BC (Archimedes?)}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    68
  \end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    69
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    70
  \normalsize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    71
  \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    72
  \begin{tabular}{ll}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    73
  Email:  & christian.urban at kcl.ac.uk\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    74
  %Office Hours: & Thursdays 12 -- 14\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    75
  %Location: & N7.07 (North Wing, Bush House)\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    76
  Slides \& Progs: & KEATS\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    77
  \end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    78
  \end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    79
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    80
  \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    81
    \begin{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    82
      \node[drop shadow,fill=white,inner sep=0pt] 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    83
      {\footnotesize\rowcolors{1}{capri!10}{white}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    84
        \begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    85
          \cellcolor{blue!50}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    86
          1 Introduction, Languages          & 6 While-Language \\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    87
          2 Regular Expressions, Derivatives & 7 Compilation, JVM \\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    88
          3 Automata, Regular Languages      & 8 Compiling Functional Languages \\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    89
          4 Lexing, Tokenising               & 9 Optimisations \\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    90
          5 Grammars, Parsing                & 10 LLVM \\ \hline
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    91
        \end{tabular}%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    92
      };
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    93
    \end{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    94
  \end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    95
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    96
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    97
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    98
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    99
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   100
\begin{frame}<1-12>[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   101
\frametitle{The Goal of this Module\ldots}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   102
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   103
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   104
  \begin{tikzpicture}[scale=1,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   105
                      node/.style={
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   106
                      rectangle,rounded corners=3mm,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   107
                      very thick,draw=black!50,minimum height=18mm, minimum width=20mm,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   108
                      top color=white,bottom color=black!20,drop shadow}]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   109
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   110
  \node at (3.05, 1.8) {\Large\bf \ldots{} you write a compiler};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   111
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   112
  \node (0) at (-2.3,0) {};  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   113
  \node [above=5mm of 0]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   114
  {\makebox[0mm]{\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   115
      \begin{tabular}{@{}l@{}}input\\[-1mm]program\end{tabular}}}; 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   116
     
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   117
  \node (A) at (0,0)  [node] {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   118
  \node [below right] at (A.north west) {lexer};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   119
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   120
  \node (B) at (3,0)  [node] {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   121
  \node [below right=1mm] at (B.north west) {\mbox{}\hspace{-1mm}parser};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   122
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   123
  \node (C) at (6,0)  [node] {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   124
  \node [below right] at (C.north west) {\mbox{}\hspace{-1mm}code gen};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   125
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   126
  \node (1) at (8.4,0) {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   127
  \node [above=5mm of 1]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   128
  {\makebox[0mm]{\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   129
      \begin{tabular}{@{}r@{}}binary\\[-1mm]code\end{tabular}}};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   130
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   131
  \draw [->,line width=4mm] (0) -- (A); 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   132
  \draw [->,line width=4mm] (A) -- (B); 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   133
  \draw [->,line width=4mm] (B) -- (C); 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   134
  \draw [->,line width=4mm] (C) -- (1); 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   135
  \end{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   136
  \end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   137
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   138
\only<2,3,4>{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   139
\begin{textblock}{1}(1,2.1)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   140
\begin{bubble}[9.8cm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   141
\normalsize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   142
lexer input: a string\smallskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   143
\hspace{5mm}\code{"read(n);"}\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   144
lexer output: a sequence of tokens\smallskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   145
\hspace{5mm}\code{key(read) lpar id(n) rpar semi}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   146
\end{bubble}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   147
\end{textblock}} 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   148
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   149
\only<3,4>{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   150
\begin{textblock}{1}(6,7.8)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   151
\begin{tabular}{c}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   152
\includegraphics[scale=0.2]{../pics/rosetta.jpg}\\[-2mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   153
\footnotesize lexing $\Rightarrow$ recognising words (Stone of Rosetta)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   154
\end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   155
\end{textblock}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   156
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   157
\only<4>{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   158
\begin{textblock}{1}(0.5,12)\small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   159
\begin{tabular}{l@{}c@{}l}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   160
  \pcode{if}    & $\;\Rightarrow\;$ & keyword\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   161
  \pcode{iffoo} & $\;\Rightarrow\;$ & identifier\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   162
\end{tabular}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   163
\end{textblock}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   164
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   165
\only<6>{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   166
\begin{textblock}{1}(1,1.5)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   167
\begin{bubble}[8.5cm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   168
\normalsize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   169
parser input: a sequence of tokens\smallskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   170
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   171
{\small\hspace{5mm}\code{key(read) lpar id(n) rpar semi}}\smallskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   172
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   173
parser output: an abstract syntax tree\smallskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   174
\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   175
\hspace{2cm}\begin{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   176
  \node {\code{read}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   177
    child {node {\code{lpar}}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   178
    child {node {\code{n}}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   179
    child {node {\code{rpar}}};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   180
\end{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   181
\end{bubble}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   182
\end{textblock}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   183
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   184
\only<8,9>{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   185
\begin{textblock}{1}(1,1.5)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   186
\begin{bubble}[4cm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   187
\normalsize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   188
code generation:\smallskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   189
\hspace{5mm}\code{istore 2}\\ 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   190
\hspace{5mm}\code{iload 2}\\ 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   191
\hspace{5mm}\code{ldc 10}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   192
\hspace{5mm}\code{isub}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   193
\hspace{5mm}\code{ifeq Label2}\\ 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   194
\hspace{5mm}\code{iload 2}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   195
\hspace{5mm}\code{...}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   196
\end{bubble}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   197
\end{textblock}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   198
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   199
\only<9>{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   200
\begin{textblock}{6}(8.4,7)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   201
\begin{bubble}[5cm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   202
\mbox{\begin{tikzpicture}[scale=0.58,rounded corners=0mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   203
\begin{axis}[axis x line=bottom, axis y line=left, ylabel=secs,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   204
    xlabel=n,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   205
    enlargelimits=0.05,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   206
    ybar interval=0.7, legend style=small]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   207
\addplot file {interpreted2.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   208
\addplot file {compiled2.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   209
%\legend{interpreted, compiled}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   210
\end{axis}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   211
\end{tikzpicture}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   212
\end{bubble}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   213
\end{textblock}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   214
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   215
\only<10>{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   216
\begin{textblock}{6}(1,3)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   217
  \begin{bubble}[11cm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   218
    Compiler explorers, e.g.: \url{https://gcc.godbolt.org} \;\video{https://youtu.be/ysaBmhMEyUg}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   219
  \begin{tikzpicture}[]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   220
  \node (0) at (-2.3,0) {\includegraphics[scale=0.3]{pics/csource.png}};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   221
  \node (1) [right=35mm] at (0) {\includegraphics[scale=0.3]{pics/cassmbl.png}}; 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   222
  \draw [->,line width=4mm, red] (0) -- (1);   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   223
  \node (2) [below=20mm] at (0) {\LARGE\bf source};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   224
  \node (3) [right=40mm] at (2) {\LARGE\bf binary};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   225
  \draw [->,line width=1mm] (2) -- (3);   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   226
\end{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   227
\end{bubble}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   228
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   229
\end{textblock}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   230
\only<11>{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   231
\begin{textblock}{6}(1,3)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   232
  \begin{bubble}[11cm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   233
    Compiler explorer for Java: \url{https://javap.yawk.at} 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   234
  \begin{tikzpicture}[]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   235
  \node (0) at (-2.3,0) {\includegraphics[scale=0.4]{pics/jsource.png}};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   236
  \node (1) [right=35mm] at (0) {\includegraphics[scale=0.4]{pics/jassmbl.png}}; 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   237
  \draw [->,line width=4mm, red] (0) -- (1);   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   238
  \node (2) [below=20mm] at (0) {\LARGE\bf source};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   239
  \node (3) [right=40mm] at (2) {\LARGE\bf byte code};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   240
  \draw [->,line width=1mm] (2) -- (3);   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   241
\end{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   242
\end{bubble}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   243
\end{textblock}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   244
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   245
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   246
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   247
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   248
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   249
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   250
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   251
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   252
\begin{frame}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   253
\frametitle{Why Study Compilers?}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   254
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   255
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   256
John Regehr {\small(Univ.~Utah, LLVM compiler hacker)}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   257
\here{https://blog.regehr.org/archives/1419}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   258
\smallskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   259
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   260
\begin{bubble}[10.5cm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   261
  \bf ``\ldots{}It’s effectively a perpetual
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   262
  employment act for solid compiler hackers.''
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   263
\end{bubble}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   264
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   265
\onslide<1->{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   266
\only<2>{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   267
\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   268
\item {\bf Hardware is getting weirder
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   269
  rather than getting clocked faster.}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   270
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   271
\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   272
\item[]  ``Almost all processors are multicores nowadays and it looks
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   273
  like there is increasing asymmetry in resources across cores.
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   274
  Processors come with vector units, crypto accelerators etc. We have
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   275
  DSPs, GPUs, ARM big.little, and Xeon Phi. This is only scratching the
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   276
  surface.''
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   277
\end{itemize}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   278
\end{itemize}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   279
\only<3>{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   280
\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   281
\item {\bf We’re getting tired of low-level languages and
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   282
    their associated security disasters.}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   283
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   284
\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   285
\item [] ``We want to write new code, to whatever extent possible, in
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   286
  safer, higher-level languages. Compilers are caught right in the
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   287
  middle of these opposing trends: one of their main jobs is to help
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   288
  bridge the large and growing gap between increasingly high-level
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   289
  languages and increasingly wacky platforms.''
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   290
\end{itemize}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   291
\end{itemize}}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   292
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   293
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   294
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   295
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   296
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   297
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   298
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   299
\frametitle{Why Bother with Compilers?}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   300
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   301
\textbf{Boeing 777's}: First flight in 1994. They want to achieve
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   302
triple redundancy for potential hardware faults.
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   303
\here{http://www.citemaster.net/get/db3a81c6-548e-11e5-9d2e-00163e009cc7/R8.pdf}\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   304
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   305
They compile 1 Ada program to\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   306
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   307
\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   308
  \item Intel 80486
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   309
  \item Motorola 68040 (old Macintosh's)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   310
  \item AMD 29050 (RISC chips used often in laser printers)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   311
\end{itemize}\medskip\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   312
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   313
using 3 independent compilers.\bigskip\pause
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   314
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   315
\small Airbus uses C and static analysers. Recently started using CompCert.
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   316
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   317
\only<1->{%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   318
\begin{textblock}{6}(8,4.5)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   319
\includegraphics[scale=0.28]{../pics/777.png}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   320
\end{textblock}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   321
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   322
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   323
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   324
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   325
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   326
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   327
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   328
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   329
\frametitle{What Do Compilers Do?}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   330
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   331
Remember BF*** from PEP?
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   332
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   333
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   334
\begin{tabular}{rcl}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   335
\bl{\texttt{>}} & $\Rightarrow$ & move one cell right\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   336
\bl{\texttt{<}} & $\Rightarrow$ & move one cell left\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   337
\bl{\texttt{+}} & $\Rightarrow$ & increase cell by one\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   338
\bl{\texttt{-}} & $\Rightarrow$ & decrease cell by one\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   339
\bl{\texttt{.}} & $\Rightarrow$ & print current cell\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   340
\bl{\texttt{,}} & $\Rightarrow$ & input current cell\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   341
\bl{\texttt{[}} & $\Rightarrow$ & loop begin\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   342
\bl{\texttt{]}} & $\Rightarrow$ & loop end\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   343
                & $\Rightarrow$ & everything else is a comment\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   344
\end{tabular}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   345
\end{center}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   346
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   347
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   348
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   349
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   350
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   351
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   352
  \frametitle{A ``Compiler'' for BF*** to C}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   353
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   354
  \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   355
  \begin{tabular}{rcl}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   356
  \bl{\texttt{>}} & $\Rightarrow$ & \texttt{ptr++}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   357
  \bl{\texttt{<}} & $\Rightarrow$ & \texttt{ptr--}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   358
  \bl{\texttt{+}} & $\Rightarrow$ & \texttt{(*ptr)++}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   359
  \bl{\texttt{-}} & $\Rightarrow$ & \texttt{(*ptr)--}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   360
  \bl{\texttt{.}} & $\Rightarrow$ & \texttt{putchar(*ptr)}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   361
  \bl{\texttt{,}} & $\Rightarrow$ & \texttt{*ptr = getchar()}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   362
  \bl{\texttt{[}} & $\Rightarrow$ & \texttt{while(*ptr)\{}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   363
  \bl{\texttt{]}} & $\Rightarrow$ & \texttt{\}}\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   364
                  & $\Rightarrow$ & ignore everything else\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   365
  \end{tabular}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   366
  \end{center}\bigskip  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   367
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   368
  \texttt{char field[30000]\\ char *ptr = \&field[15000]}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   369
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   370
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   371
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   372
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   373
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   374
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   375
  \frametitle{Another~``Compiler''~for~BF~to~C}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   376
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   377
  \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   378
  \begin{tabular}{rcl}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   379
  \bl{\texttt{>\ldots>}} & $\Rightarrow$ & \texttt{ptr += n}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   380
  \bl{\texttt{<\ldots<}} & $\Rightarrow$ & \texttt{ptr -= n}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   381
  \bl{\texttt{+\ldots+}} & $\Rightarrow$ & \texttt{(*ptr) += n}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   382
  \bl{\texttt{-\ldots-}} & $\Rightarrow$ & \texttt{(*ptr) -= n}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   383
  \bl{\texttt{.}} & $\Rightarrow$ & \texttt{putchar(*ptr)}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   384
  \bl{\texttt{,}} & $\Rightarrow$ & \texttt{*ptr = getchar()}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   385
  \bl{\texttt{[}} & $\Rightarrow$ & \texttt{while(*ptr)\{}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   386
  \bl{\texttt{]}} & $\Rightarrow$ & \texttt{\}}\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   387
                  & $\Rightarrow$ & ignore everything else\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   388
  \end{tabular}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   389
  \end{center}\bigskip  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   390
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   391
  \texttt{char field[30000]\\ char *ptr = \&field[15000]}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   392
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   393
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   394
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   395
    
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   396
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   397
\begin{frame}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   398
\frametitle{A Brief Compiler History}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   399
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   400
\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   401
\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   402
\item Turing Machines, 1936 (a tape as memory)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   403
\item Regular Expressions, 1956\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   404
\item The first compiler for COBOL, 1957\\ (Grace Hopper)\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   405
\item But surprisingly research papers are still published nowadays\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   406
\item ``Parsing: The Solved Problem That Isn't''
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   407
  \here{https://tratt.net/laurie/blog/entries/parsing_the_solved_problem_that_isnt.html}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   408
\end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   409
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   410
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   411
\begin{textblock}{8.5}(5,7.6)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   412
\begin{flushright}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   413
\includegraphics[scale=0.3]{pics/hopper.jpg}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   414
\footnotesize\textcolor{gray}{Grace Hopper}\smallskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   415
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   416
{\small\textcolor{gray}{(she made it to David Letterman's Tonight Show
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   417
 \here{https://youtu.be/3N_ywhx6_K0?t=31})}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   418
\end{flushright}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   419
\end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   420
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   421
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   422
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   423
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   424
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   425
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   426
\frametitle{Some Housekeeping}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   427
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   428
\textbf{Exam will be online:}\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   429
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   430
\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   431
\item final exam in January (35\%)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   432
\item five CWs (65\%) 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   433
\end{itemize}\bigskip\bigskip\pause
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   434
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   435
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   436
\textbf{Weekly Homework (optional):}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   437
\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   438
\item uploaded on KEATS, send answers via email, (try to!) respond individually
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   439
\item \alert{\bf all} questions in the exam will be from the HWs!!
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   440
\end{itemize}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   441
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   442
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   443
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   444
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   445
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   446
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   447
\frametitle{Some Housekeeping}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   448
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   449
\textbf{Coursework (5 accounting for 65\%):}\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   450
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   451
\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   452
\item matcher (5\%)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   453
\item lexer (10\%)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   454
\item parser / interpreter (10\%)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   455
\item JVM compiler (15\%)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   456
\item LLVM compiler (25\%) 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   457
\end{itemize}\bigskip\pause
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   458
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   459
you can use \alert{any} programming language you like (Haskell, Rust)\\\pause
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   460
you can use any code I show you and is uploaded to KEATS\ldots\textbf{BUT NOTHING ELSE!}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   461
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   462
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   463
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   464
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   465
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   466
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   467
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   468
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   469
\frametitle{Lectures 1 - 5}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   470
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   471
transforming strings into structured data\\[10mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   472
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   473
{\LARGE\bf Lexing} {\hfill{}based on regular expressions}\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   474
\hspace{5mm}(recognising ``words'')\\[6mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   475
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   476
{\LARGE\bf Parsing}\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   477
\hspace{5mm}(recognising ``sentences'')
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   478
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   479
\begin{textblock}{1}(10,9.1)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   480
\begin{tabular}{c}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   481
\includegraphics[scale=0.1]{../pics/rosetta.jpg}\\[-2mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   482
\footnotesize Stone of Rosetta
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   483
\end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   484
\end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   485
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   486
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   487
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   488
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   489
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   490
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   491
\frametitle{Lectures 1 - 5}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   492
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   493
transforming strings into structured data\\[10mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   494
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   495
{\LARGE\bf Lexing} {\hfill{}based on regular expressions}\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   496
\hspace{5mm}(recognising ``words'')\\[6mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   497
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   498
{\LARGE\bf Parsing}\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   499
\hspace{5mm}(recognising ``sentences'')
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   500
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   501
\begin{textblock}{1}(10,9.1)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   502
\begin{tabular}{c}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   503
\includegraphics[scale=0.1]{../pics/rosetta.jpg}\\[-2mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   504
\footnotesize Stone of Rosetta
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   505
\end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   506
\end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   507
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   508
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   509
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   510
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   511
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   512
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   513
  \frametitle{Lectures 5 - 10}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   514
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   515
  code generation for a small imperative and a small functional language\\[10mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   516
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   517
  {\LARGE\bf Interpreters}\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   518
  \hspace{5mm}(directly runs a program)\\[6mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   519
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   520
  {\LARGE\bf Compilers}\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   521
  \hspace{5mm}(generate JVM code and LLVM-IR code)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   522
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   523
  \begin{textblock}{1}(8.8,8.1)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   524
  \begin{tabular}{c@{}c}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   525
    \includegraphics[scale=0.4]{../pics/javaduke.png} &
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   526
    \includegraphics[scale=0.23]{../pics/llvmlogo.png}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   527
  \end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   528
  \end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   529
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   530
  \end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   531
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   532
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   533
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   534
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   535
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   536
\begin{frame}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   537
\frametitle{Familiar Regular Expresssions}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   538
\small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   539
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   540
\texttt{[a-z0-9\_$\backslash{}$.-]+ @ [a-z0-9$\backslash{}$.-]+ . [a-z$\backslash{}$.]\{2,6\}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   541
\end{center}\smallskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   542
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   543
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   544
\begin{tabular}{@{}lp{8.5cm}@{}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   545
\pcode{re*} & matches 0 or more times\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   546
\pcode{re+} & matches 1 or more times\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   547
\pcode{re?} & matches 0 or 1 times\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   548
\pcode{re\{n\}}	& matches exactly \pcode{n} number of times\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   549
\pcode{re\{n,m\}} & matches at least \pcode{n} and at most {\tt m} times\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   550
\pcode{[...]} & matches any single character inside the brackets\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   551
\pcode{[^...]} & matches any single character not inside the 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   552
brackets\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   553
\pcode{a-z A-Z} & character ranges\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   554
\pcode{\\d} & matches digits; equivalent to \pcode{[0-9]}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   555
\pcode{.} & matches every character except newline\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   556
\pcode{(re)}	& groups regular expressions and remembers 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   557
the matched text
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   558
\end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   559
\end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   560
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   561
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   562
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   563
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   564
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   565
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   566
\frametitle{Some ``innocent'' examples}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   567
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   568
Let's try two examples
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   569
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   570
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   571
  \bl{\texttt{(a*)*b}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   572
  \hspace{2cm}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   573
  \bl{\texttt{[a?]\{n\}[a]\{n\}}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   574
\end{center}\bigskip\pause  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   575
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   576
and match them with strings of the form
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   577
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   578
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   579
  \bl{\texttt{a}},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   580
  \bl{\texttt{aa}},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   581
  \bl{\texttt{aaa}},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   582
  \bl{\texttt{aaaa}},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   583
  \bl{\texttt{aaaaa}},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   584
  \bl{$\underbrace{\texttt{a}...\texttt{a}}_n$}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   585
\end{center}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   586
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   587
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   588
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   589
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   590
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   591
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   592
\frametitle{Why Bother with Regexes?}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   593
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   594
\begin{columns}[t,onlytextwidth]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   595
\begin{column}{1.8cm}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   596
\mbox{}   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   597
\end{column}    
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   598
\begin{column}{.5\textwidth}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   599
\small{}Ruby, Python, Java 8\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   600
\begin{tikzpicture}\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   601
\begin{axis}[
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   602
    xlabel={$n$},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   603
    x label style={at={(1.05,0.0)}},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   604
    ylabel={time in secs},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   605
    enlargelimits=false,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   606
    xtick={0,5,...,30},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   607
    xmax=33,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   608
    ymax=35,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   609
    ytick={0,5,...,30},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   610
    scaled ticks=false,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   611
    axis lines=left,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   612
    width=\textwidth,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   613
    height=4cm, 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   614
    legend entries={Python,Ruby},  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   615
    legend pos=north west,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   616
    legend cell align=left]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   617
\addplot[blue,mark=*, mark options={fill=white}] table {re-python.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   618
\addplot[brown,mark=triangle*, mark options={fill=white}] table {re-ruby.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   619
\end{axis}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   620
\end{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   621
\begin{tikzpicture}\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   622
\begin{axis}[
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   623
    xlabel={$n$},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   624
    x label style={at={(1.05,0.0)}},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   625
    ylabel={time in secs},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   626
    enlargelimits=false,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   627
    xtick={0,5,...,30},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   628
    xmax=33,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   629
    ymax=35,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   630
    ytick={0,5,...,30},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   631
    scaled ticks=false,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   632
    axis lines=left,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   633
    width=\textwidth,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   634
    height=4cm, 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   635
    legend entries={Python, Java 8, JavaScript, Swift},  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   636
    legend pos=north west,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   637
    legend cell align=left]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   638
\addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   639
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   640
\addplot[red,mark=*, mark options={fill=white}] table {re-js.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   641
\addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   642
\end{axis}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   643
\end{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   644
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   645
\end{column}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   646
\begin{column}{.5\textwidth}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   647
\small{}Us (after next lecture)\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   648
\begin{tikzpicture}\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   649
\begin{axis}[
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   650
    xlabel={$n$},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   651
    x label style={at={(1.07,0.0)}},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   652
    ylabel={time in secs},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   653
    enlargelimits=false,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   654
    xtick={0,5000,...,10000},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   655
    xmax=11000,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   656
    ymax=35,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   657
    ytick={0,5,...,30},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   658
    scaled ticks=false,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   659
    axis lines=left,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   660
    width=\textwidth,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   661
    height=4cm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   662
\addplot[green,mark=square*,mark options={fill=white}] table {re2.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   663
\addplot[black,mark=square*,mark options={fill=white}] table {re3.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   664
\end{axis}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   665
\end{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   666
\begin{tikzpicture}\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   667
\begin{axis}[
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   668
    xlabel={$n$},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   669
    x label style={at={(1.07,0.0)}},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   670
    ylabel={time in secs},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   671
    enlargelimits=false,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   672
    ymax=35,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   673
    ytick={0,5,...,30},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   674
    scaled ticks=false,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   675
    axis lines=left,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   676
    width=\textwidth,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   677
    height=4cm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   678
\addplot[black,mark=square*,mark options={fill=white}] table {re3a.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   679
\end{axis}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   680
\end{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   681
\end{column}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   682
\end{columns}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   683
\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   684
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   685
\begin{textblock}{3}(-0.1,3.3)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   686
\small\hfill\bl{\texttt{[a?]\{n\}[a]\{n\}}}:
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   687
\end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   688
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   689
\begin{textblock}{3}(-0.1,8.7)  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   690
\small\hfill\bl{\texttt{(a*)*b}}:
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   691
\end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   692
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   693
\begin{textblock}{3}(0.3,13)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   694
\small{}matching with strings
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   695
\bl{$\underbrace{\texttt{a}...\texttt{a}}_n$}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   696
\end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   697
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   698
\end{frame} 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   699
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   700
    
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   701
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   702
\begin{frame}[c,fragile]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   703
  \frametitle{Incidents}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   704
    
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   705
  \begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   706
  \item a global outage on 2 July 2019 at \textbf{Cloudflare} 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   707
  (first one for six years)\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   708
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   709
  \begin{center}\small\color{blue}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   710
  \begin{verbatim}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   711
  (?:(?:\"|'|\]|\}|\\|\d|(?:nan|infinity|true|false|
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   712
  null|undefined|symbol|math)|\`|\-|\+)+[)]*;?((?:\s
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   713
  |-|~|!|{}|\|\||\+)*.*(?:.*=.*)))  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   714
  \end{verbatim}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   715
  \end{center}\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip    
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   716
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   717
  \item on 20 July 2016 the \textbf{Stack Exchange} webpage went down
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   718
    because of an evil regular expression
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   719
    \here{https://stackstatus.net/post/147710624694/outage-postmortem-july-20-2016}    
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   720
  \end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   721
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   722
  \begin{textblock}{6}(6,7.6)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   723
    \includegraphics[scale=0.14]{../pics/cloudflare.png}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   724
    \footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   725
    It serves more web traffic than Twitter, Amazon, Apple,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   726
    Instagram, Bing \& Wikipedia combined.
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   727
    \here{https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019/}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   728
    \end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   729
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   730
  \end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   731
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   732
    
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   733
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   734
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   735
\frametitle{Evil Regular Expressions}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   736
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   737
\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   738
\item \alert{R}egular \alert{e}xpression \alert{D}enial \alert{o}f \alert{S}ervice (ReDoS)\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   739
\item Some evil regular expressions:\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   740
\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   741
\item \bl{\texttt{[a?]\{n\}\;[a]\{n\}}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   742
\item \bl{\texttt{(a*)*\;b}}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   743
\item \bl{\texttt{([a-z]+)*}} 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   744
\item \bl{\texttt{(a + aa)*}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   745
\item \bl{\texttt{(a + a?)*}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   746
\end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   747
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   748
\item sometimes also called \alert{catastrophic backtracking}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   749
\item this is a problem for \alert{N}etwork \alert{I}ntrusion
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   750
  \alert{D}etection systems, Cloudflare, StackExchange, Atom editor
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   751
\item \url{https://vimeo.com/112065252}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   752
\end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   753
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   754
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   755
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   756
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   757
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   758
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   759
%\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   760
%\frametitle{Today}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   761
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   762
%\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   763
%\item While the ultimate goal is to implement a small compiler for the JVM
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   764
%  \ldots\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   765
%\end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   766
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   767
%Let's start with:
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   768
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   769
%\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   770
%\item a web-crawler
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   771
%\item an email harvester
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   772
%\item \textcolor{gray}{(a web-scraper)}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   773
%\end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   774
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   775
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   776
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   777
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   778
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   779
%\begin{frame}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   780
%\frametitle{A Web-Crawler}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   781
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   782
%\mbox{}\\[10mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   783
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   784
%\begin{enumerate}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   785
%\item given an URL, read the corresponding webpage
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   786
%\item extract all links from it
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   787
%\item call the web-crawler again for all these links
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   788
%\end{enumerate}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   789
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   790
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   791
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   792
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   793
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   794
%\begin{frame}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   795
%\frametitle{A Web-Crawler}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   796
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   797
%\mbox{}\\[10mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   798
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   799
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   800
%\begin{enumerate}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   801
%\item given an URL, read the corresponding webpage
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   802
%\item if not possible print, out a problem
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   803
%\item if possible, extract all links from it
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   804
%\item call the web-crawler again for all these links
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   805
%\end{enumerate}\bigskip\pause
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   806
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   807
%\small (we need a bound for the number of recursive calls)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   808
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   809
%\small (the purpose is to check all links on my own webpage)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   810
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   811
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   812
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   813
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   814
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   815
%\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   816
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   817
%\begin{textblock}{1}(2,5)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   818
%\begin{tabular}{c}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   819
%\includegraphics[scale=0.15]{pics/servers.png}\\[-2mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   820
%\small Server
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   821
%\end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   822
%\end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   823
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   824
%\begin{textblock}{1}(5.6,4)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   825
%  \begin{tikzpicture}[scale=1.1]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   826
%  \draw[white] (0,1) node (X) {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   827
%  \draw[white] (2,1) node (Y) {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   828
%   \draw[white] (0,0) node (X1) {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   829
%  \draw[white] (2,0) node (Y1) {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   830
%   \draw[white] (0,-1) node (X2) {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   831
%  \draw[white] (2,-1) node (Y2) {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   832
%  \draw[red, <-, line width = 2mm] (X) -- (Y);
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   833
%  \node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   834
%  \draw[red, ->, line width = 2mm] (X1) -- (Y1);
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   835
%  \node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   836
%  \draw[red, <-, line width = 2mm] (X2) -- (Y2);
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   837
%  \node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   838
%  \end{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   839
%\end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   840
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   841
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   842
%\begin{textblock}{1}(9,5.5)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   843
%\begin{tabular}{c}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   844
%\includegraphics[scale=0.15]{pics/laptop.png}\\[-2mm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   845
%\small Browser
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   846
%\end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   847
%\end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   848
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   849
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   850
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   851
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   852
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   853
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   854
%\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   855
%\frametitle{Scala}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   856
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   857
%\small A simple Scala function for reading webpages:
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   858
%\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   859
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   860
%\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   861
%\lstinputlisting{../progs/app0.scala}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   862
%\medskip\pause
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   863
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   864
%\lstinline{get_page("""https://nms.kcl.ac.uk/christian.urban/""")}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   865
%\bigskip\medskip\pause
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   866
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   867
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   868
%\small A slightly more complicated version for handling errors:
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   869
%\smallskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   870
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   871
%\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   872
%\lstinputlisting[xleftmargin=-4mm]{../progs/app1.scala}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   873
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   874
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   875
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   876
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   877
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   878
 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   879
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   880
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   881
%\begin{frame}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   882
%\frametitle{A Regular Expression}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   883
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   884
%\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   885
%\item \ldots{} is a pattern or template for specifying strings
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   886
%\end{itemize}\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   887
%  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   888
%\begin{center}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   889
%\only<1>{\scode{"https?://[^"]*"}}%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   890
%\only<2>{\scode{""""https?://[^"]*"""".r}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   891
%\end{center}\bigskip\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   892
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   893
%matches for example\smallskip\\  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   894
%\hspace{2mm}\code{"http://www.foobar.com"}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   895
%\hspace{2mm}\code{"https://www.tls.org"}\smallskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   896
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   897
%but not\smallskip\\  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   898
%\hspace{2mm}\code{"http://www."foo"bar.com"}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   899
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   900
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   901
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   902
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   903
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   904
%\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   905
%\frametitle{Finding Operations in Scala}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   906
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   907
%{\bf\code{rexp.findAllIn(string)}}\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   908
%  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   909
%returns a list of all (sub)strings that match the 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   910
%regular expression
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   911
%\bigskip\bigskip  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   912
%  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   913
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   914
%{\bf\code{rexp.findFirstIn(string)}}\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   915
% 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   916
%returns either 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   917
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   918
%\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   919
%\item \code{None} if no (sub)string matches or 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   920
%\item \code{Some(s)} with the first (sub)string
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   921
%\end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   922
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   923
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   924
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   925
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   926
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   927
%\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   928
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   929
%\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   930
%\lstinputlisting{../progs/app2.scala}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   931
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   932
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   933
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   934
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   935
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   936
%\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   937
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   938
%\small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   939
%A version that only crawls links in ``my'' domain:\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   940
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   941
%\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   942
%\lstinputlisting{../progs/app3.scala}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   943
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   944
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   945
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   946
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   947
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   948
%\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   949
%\lstset{xleftmargin=-4mm}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   950
%\small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   951
%A little email harvester:
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   952
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   953
%\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   954
%\lstinputlisting{../progs/app4.scala}\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   955
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   956
%\tiny
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   957
%\url{http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   958
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   959
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   960
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   961
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   962
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   963
\begin{frame}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   964
\frametitle{(Basic) Regular Expressions}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   965
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   966
Their inductive definition:
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   967
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   968
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   969
\begin{textblock}{6}(2,7.5)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   970
  \begin{tabular}{@ {}rrl@ {\hspace{13mm}}l}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   971
  \bl{$r$} & \bl{$::=$}  & \bl{$\ZERO$}  & nothing\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   972
         & \bl{$\mid$} & \bl{$\ONE$}       & empty string / \pcode{""} / $[]$\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   973
         & \bl{$\mid$} & \bl{$c$}                         & character\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   974
         & \bl{$\mid$} & \bl{$r_1 + r_2$}  & alternative / choice\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   975
         & \bl{$\mid$} & \bl{$r_1 \cdot r_2$} & sequence\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   976
         & \bl{$\mid$} & \bl{$r^*$}            & star (zero or more)\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   977
  \end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   978
  \end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   979
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   980
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   981
\only<2->{\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   982
\begin{textblock}{9}(2,0.5)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   983
\begin{bubble}[9.8cm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   984
\lstinputlisting{../progs/app01.scala}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   985
\end{bubble}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   986
\end{textblock}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   987
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   988
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   989
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   990
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   991
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   992
%\begin{frame}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   993
%\frametitle{Regular Expressions}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   994
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   995
%\small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   996
%In Scala:\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   997
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   998
%\footnotesize
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
   999
%\lstinputlisting{../progs/app51.scala}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1000
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1001
%  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1002
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1003
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1004
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1005
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1006
\begin{frame}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1007
\frametitle{Strings}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1008
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1009
\ldots are lists of characters. For example \code{"hello"}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1010
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1011
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1012
\bl{$[h, e, l, l, o]$} or just \bl{$hello$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1013
\end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1014
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1015
the empty string: \bl{$[]$} or \bl{\pcode{""}}\bigskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1016
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1017
the concatenation of two strings:
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1018
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1019
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1020
\bl{$s_1 \,@\, s_2$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1021
\end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1022
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1023
\bl{\textit{foo $@$ bar = foobar}}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1024
\bl{\textit{baz $@\, []$ = baz}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1025
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1026
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1027
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1028
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1029
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1030
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1031
\frametitle{Languages, Strings}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1032
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1033
\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1034
\item \alert{\bf Strings} are lists of characters, for example
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1035
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1036
\bl{$[]$},\;\bl{$abc$}  \hspace{2cm}(Pattern match: \bl{$c\!::\!s$})
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1037
\end{center}\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1038
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1039
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1040
\item A \alert{\bf language} is a set of strings, for example\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1041
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1042
\bl{$\{[], hello, \textit{foobar}, a, abc\}$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1043
\end{center}\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1044
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1045
\item \alert{\bf Concatenation} of strings and languages
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1046
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1047
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1048
\begin{tabular}{rcl}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1049
\bl{$\textit{foo}\;@\;bar$} & \bl{$=$} & \bl{$\textit{foobar}$}\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1050
\bl{$A\;@\;B$} & \bl{$\dn$} & \bl{$\{ s_1\,@\,s_2 \;\mid\; s_1 \in A \wedge s_2 \in B\}$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1051
\end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1052
\end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1053
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1054
%\item The \alert{\bf meaning} of a regular expression is a set of 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1055
%  strings, or language.
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1056
\end{itemize}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1057
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1058
\only<2>{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1059
\begin{textblock}{4}(10.5,8)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1060
\small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1061
Let
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1062
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1063
\bl{$A = \{foo, bar\}$} \bl{$B = \{a, b\}$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1064
\[
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1065
\bl{A \,@\, B = \{fooa, foob, bara, barb\}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1066
\]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1067
\end{textblock}}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1068
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1069
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1070
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1071
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1072
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1073
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1074
  \frametitle{Two Corner Cases}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1075
   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1076
  \Large
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1077
  \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1078
  \bl{$A \,@\, \{[]\} = \;?$}\bigskip\bigskip\pause\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1079
  \bl{$A \,@\, \{\} = \;?$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1080
  \end{center}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1081
    
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1082
  \end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1083
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1084
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1085
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1086
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1087
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1088
\frametitle{The Meaning of a Regex}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1089
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1090
 ...all the strings a regular expression can match.   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1091
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1092
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1093
 \begin{tabular}{rcl}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1094
 \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1095
 \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1096
 \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1097
 \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1098
 \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \,@\, L(r_2)$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1099
 \bl{$L(r^*)$}           & \bl{$\dn$} & \\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1100
  \end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1101
\end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1102
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1103
\begin{textblock}{14}(1.5,13.5)\small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1104
\bl{$L$} is a function from regular expressions to 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1105
sets of strings (languages):\smallskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1106
\bl{\quad$L$ : Rexp $\Rightarrow$ Set$[$String$]$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1107
\end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1108
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1109
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1110
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1111
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1112
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1113
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1114
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1115
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1116
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1117
  \frametitle{The Power Operation}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1118
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1119
  \begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1120
  \item The \alert{\textbf{\boldmath$n$th Power}} of a language:
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1121
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1122
  \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1123
  \begin{tabular}{lcl}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1124
  \bl{$A^0$}    & \bl{$\dn$} & \bl{$\{[]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1125
  \bl{$A^{n+1}$} & \bl{$\dn$} & \bl{$A \,@\, A^n$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1126
  \end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1127
  \end{center}\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1128
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1129
  \item[] For example
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1130
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1131
  \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1132
  \begin{tabular}{lcl@{\hspace{10mm}}l}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1133
  \bl{$A^4$} & \bl{$=$} & \bl{$A \,@\, A \,@\, A \,@\, A$} & \bl{$(@\,\{[]\})$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1134
  \bl{$A^1$} & \bl{$=$} & \bl{$A$} & \bl{$(@\,\{[]\})$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1135
  \bl{$A^0$} & \bl{$=$} & \bl{$\{[]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1136
  \end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1137
  \end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1138
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1139
  \end{itemize}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1140
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1141
  \end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1142
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1143
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1144
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1145
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1146
\frametitle{The Meaning of a Regex}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1147
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1148
\begin{textblock}{15}(1,4)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1149
 \begin{tabular}{rcl}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1150
 \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1151
 \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1152
 \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1153
 \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1154
 \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$\{ s_1 \,@\, s_2 \;|\; s_1 \in L(r_1) \wedge s_2 \in L(r_2) \}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1155
 \bl{$L(r^*)$}           & \bl{$\dn$} & \onslide<2->{\bl{$\bigcup_{0 \le n} L(r)^n$}}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1156
  \end{tabular}\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1157
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1158
%\onslide<2->{
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1159
%\hspace{5mm}\bl{$L(r)^0 \;\dn\; \{[]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1160
%\bl{$L(r)^{n+1} \;\dn\; L(r) \,@\, L(r)^n$}\hspace{9mm}\onslide<3->{\small\textcolor{gray}{(append on sets)}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1161
%\small\hspace{5cm}\textcolor{gray}{$\{ s_1 @ s_2 \;|\; s_1\in L(r) \wedge s_2 \in L(r)^n \}$}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1162
%}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1163
\end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1164
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1165
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1166
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1167
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1168
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1169
  \frametitle{The Star Operation}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1170
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1171
  \begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1172
  \item The \alert{\bf Kleene Star} of a \underline{language}:
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1173
  \bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1174
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1175
  \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1176
  \begin{tabular}{c}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1177
  \bl{$A\star \dn \bigcup_{0\le n} A^n$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1178
  \end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1179
  \end{center}\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1180
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1181
  \item[] This expands to 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1182
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1183
  \[
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1184
  \bl{A^0 \cup A^1 \cup A^2 \cup A^3 \cup A^4 \cup \ldots}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1185
  \]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1186
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1187
  or
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1188
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1189
  \small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1190
  \[
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1191
  \bl{\{[]\} \;\cup\; A \;\cup\; A\,@\,A \;\cup\; 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1192
    A\,@\,A\,@\,A \;\cup\; A\,@\,A\,@\,A\,@\,A \cup \ldots}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1193
  \]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1194
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1195
  \end{itemize}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1196
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1197
  \end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1198
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1199
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1200
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1201
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1202
\frametitle{The Meaning of a Regex}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1203
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1204
\begin{textblock}{15}(1,4)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1205
 \begin{tabular}{rcl}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1206
 \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1207
 \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1208
 \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1209
 \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1210
 \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$\{ s_1 \,@\, s_2 \;|\; s_1 \in L(r_1) \wedge s_2 \in L(r_2) \}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1211
 \bl{$L(r^*)$}           & \bl{$\dn$} & \bl{$(L(r))\star$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1212
  \end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1213
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1214
\end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1215
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1216
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1217
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1218
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1219
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1220
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1221
\frametitle{The Meaning of Matching}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1222
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1223
\begin{bubble}[10cm]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1224
\large\bf 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1225
A regular expression \bl{$r$} matches a string~\bl{$s$} 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1226
provided
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1227
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1228
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1229
\bl{$s \in L(r)$}\\ 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1230
\end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1231
\end{bubble}\bigskip\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1232
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1233
\ldots and the point of the next lecture is 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1234
to decide this problem as fast as possible (unlike Python,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1235
Ruby, Java)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1236
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1237
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1238
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%      
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1239
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1240
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1241
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1242
  \frametitle{Questions}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1243
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1244
  \begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1245
  \item Say \bl{$A = \{[a],[b],[c],[d]\}$}.\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1246
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1247
  \item[]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1248
  How many strings are in \bl{$A^4$}\,?
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1249
  \bigskip\medskip\pause
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1250
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1251
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1252
 \item[]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1253
  What if \bl{$A = \{[a],[b],[c],[]\}$};\\ 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1254
  how many strings are then in \bl{$A^4$}\,?
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1255
  \end{itemize}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1256
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1257
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1258
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1259
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1260
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1261
% \begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1262
% \frametitle{Languages (Sets of Strings)}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1263
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1264
% \begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1265
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1266
% \item A \alert{\bf Language} is a set of strings, for example\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1267
% \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1268
% \bl{$\{[], hello, foobar, a, abc\}$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1269
% \end{center}\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1270
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1271
% \item \alert{\bf Concatenation} for strings and languages
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1272
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1273
% \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1274
% \begin{tabular}{rcl}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1275
% \bl{$foo\;@\;bar$} & \bl{$=$} & \bl{$foobar$}\medskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1276
% \bl{$A\;@\;B$}     & \bl{$\dn$} & \bl{$\{ s_1\,@\,s_2 \;\mid\; s_1 \in A \wedge s_2 \in B\}$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1277
% \end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1278
% \end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1279
% \bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1280
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1281
% \small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1282
% \item [] For example \bl{$A = \{foo, bar\}$}, \bl{$B = \{a, b\}$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1283
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1284
% \[
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1285
% \bl{A \,@\, B = \{fooa, foob, bara, barb\}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1286
% \]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1287
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1288
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1289
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1290
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1291
% \end{itemize}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1292
% \end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1293
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1294
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1295
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1296
% \begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1297
%   \frametitle{Two Corner Cases}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1298
   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1299
%   \Large
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1300
%   \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1301
%   \bl{$A \,@\, \{[]\} = \;?$}\bigskip\bigskip\pause\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1302
%   \bl{$A \,@\, \{\} = \;?$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1303
%   \end{center}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1304
    
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1305
%   \end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1306
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1307
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1308
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1309
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1310
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1311
% \begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1312
% \frametitle{The Meaning of a Regex}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1313
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1314
%  ...all the strings a regular expression can match.   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1315
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1316
% \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1317
%  \begin{tabular}{rcl}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1318
%  \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1319
%  \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1320
%  \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1321
%  \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1322
%  \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \,@\, L(r_2)$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1323
%  \bl{$L(r^*)$}           & \bl{$\dn$} & \\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1324
%   \end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1325
% \end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1326
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1327
% \begin{textblock}{14}(1.5,13.5)\small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1328
% \bl{$L$} is a function from regular expressions to 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1329
% sets of strings (languages):\smallskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1330
% \bl{\quad$L$ : Rexp $\Rightarrow$ Set$[$String$]$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1331
% \end{textblock}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1332
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1333
% \end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1334
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1335
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1336
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1337
% \begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1338
% \frametitle{The Power Operation}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1339
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1340
% \begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1341
% \item The \alert{\textbf{\boldmath$n$th Power}} of a language:
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1342
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1343
% \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1344
% \begin{tabular}{lcl}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1345
% \bl{$A^0$}    & \bl{$\dn$} & \bl{$\{[]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1346
% \bl{$A^{n+1}$} & \bl{$\dn$} & \bl{$A \,@\, A^n$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1347
% \end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1348
% \end{center}\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1349
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1350
% \item[] For example
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1351
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1352
% \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1353
% \begin{tabular}{lcl@{\hspace{10mm}}l}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1354
% \bl{$A^4$} & \bl{$=$} & \bl{$A \,@\, A \,@\, A \,@\, A$} & \bl{$(@\,\{[]\})$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1355
% \bl{$A^1$} & \bl{$=$} & \bl{$A$} & \bl{$(@\,\{[]\})$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1356
% \bl{$A^0$} & \bl{$=$} & \bl{$\{[]\}$}\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1357
% \end{tabular}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1358
% \end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1359
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1360
% \end{itemize}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1361
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1362
% \end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1363
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1364
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1365
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1366
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1367
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1368
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1369
% \begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1370
% \frametitle{Written Exam}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1371
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1372
% \begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1373
% \item Accounts for 80\%.\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1374
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1375
% \item The question ``\textit{Is this relevant for
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1376
%       the exam?}'' is very demotivating for the lecturer!\bigskip\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1377
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1378
% \item Deal: Whatever is in the homework (and is not marked
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1379
%       ``\textit{optional}'') is relevant for the exam.\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1380
      
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1381
% \item Each lecture has also a handout. There are also handouts about
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1382
% notation and Scala.      
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1383
% \end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1384
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1385
% \end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1386
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1387
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1388
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1389
% \begin{frame}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1390
% \frametitle{Coursework}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1391
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1392
% \begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1393
% \item Accounts for 20\%. Two strands. Choose \alert{\bf one}!\bigskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1394
% \end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1395
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1396
% \begin{columns}[t]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1397
% \begin{column}{.5\textwidth}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1398
% \underline{\bf Strand 1}\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1399
% \begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1400
% \item 4 programming tasks:
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1401
% \begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1402
% \item matcher (4\%, 11.10.) 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1403
% \item lexer (5\%, 04.11.)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1404
% \item parser (5\%, 22.11.)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1405
% \item compiler (6\%, 13.12.)
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1406
% \end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1407
% \item in any lang.~you like,\\ but I want to see the\\ code
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1408
% \end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1409
% \end{column}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1410
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1411
% \hspace{-45pt}\vrule{}\hspace{10pt}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1412
% \begin{column}{.5\textwidth}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1413
% \underline{\bf Strand 2}\smallskip\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1414
% \item one task: prove the correctness of a regular expression matcher in 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1415
% the \underline{Isabelle} theorem prover
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1416
% \item 20\%, submission on~13.12.\hspace{-5mm}\mbox{}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1417
% \end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1418
% \end{column}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1419
% \end{columns}\medskip
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1420
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1421
% \small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1422
% \begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1423
% \item Solving more than one strand will {\bf not} give you more 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1424
% marks.
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1425
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1426
% \end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1427
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1428
% \end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1429
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1430
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1431
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1432
%\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1433
%\frametitle{Lecture Capture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1434
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1435
%\begin{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1436
%\item Hope it works\ldots\pause actually no, it does not!\medskip\pause
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1437
%\item It is important to use lecture capture wisely\\ (it is only the ``baseline''):
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1438
%\begin{itemize}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1439
%\item Lecture recordings are a study and revision aid.
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1440
%\item Statistically, there is a clear and direct link between attendance and
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1441
%  attainment: students who do not attend lectures, do less well in exams.
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1442
%\end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1443
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1444
%\item Attending a lecture is more than watching it online -- if you do not
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1445
%attend, you miss out!  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1446
%  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1447
%\end{itemize}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1448
%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1449
%\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1450
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1451
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1452
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1453
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1454
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1455
\frametitle{\begin{tabular}{c}\\[3cm]\alert{Questions?}\end{tabular}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1456
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1457
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1458
\begin{tabular}{lll}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1459
  TAs: & Finley Warman    & (took the module last year)\\
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1460
       & Chengsong Tan    & (PhD student working on derivatives)  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1461
\end{tabular}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1462
\mbox{}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1463
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1464
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1465
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1466
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1467
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1468
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1469
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1470
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1471
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1472
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1473
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1474
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1475
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1476
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1477
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1478
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1479
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1480
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1481
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1482
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1483
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1484
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1485
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1486
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1487
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1488
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1489
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1490
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1491
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1492
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1493
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1494
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1495
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1496
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1497
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1498
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1499
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1500
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1501
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1502
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1503
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1504
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1505
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1506
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1507
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1508
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1509
\begin{mybox3}{Coursework}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1510
  Do we need to provide instructions on running the coursework files
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1511
  if we're using languages other than Scala? Thanks
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1512
\end{mybox3}\pause
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1513
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1514
\begin{mybox2}{Zip-File for Coursework}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1515
  Please, please submit a zipfile that generates a subdirectory
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1516
  \begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1517
  \texttt{NameFamilyName}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1518
  \end{center}  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1519
\end{mybox2}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1520
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1521
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1522
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1523
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1524
\begin{mybox3}{Coursework}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1525
  What is the purpose of the workshop session on the timetable?
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1526
  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1527
  Slightly confused about how to undertake cw1 and what exactly we
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1528
  should be implementing. This is more for clarification of the cw1
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1529
  structure, including the implementation and questions present in
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1530
  cw1.
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1531
\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1532
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1533
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1534
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1535
\begin{mybox3}{What is the trick?}\small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1536
  What was the trick to improve the evil regular expressions matcher
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1537
  to have such good results compared to other programming languages?
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1538
  Is it working better on casual regular expressions (the ones that
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1539
  Python and Java handle pretty well), too? Or was it just optimised
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1540
  for these evil ones?
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1541
\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1542
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1543
\begin{mybox3}{}\small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1544
  It was shown in the lectures that the pattern matching algorithms
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1545
  currently implemented in popular programming languages (Python, JS,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1546
  Java, etc) are far slower than the algorithm we are going to be
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1547
  implementing in this module. My question is why do these programming
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1548
  languages not implement the algorithm that we are going to implement
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1549
  in this module?
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1550
\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1551
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1552
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1553
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1554
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1555
  \frametitle{Thanks to Martin Mikusovic}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1556
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1557
\bigskip    
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1558
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1559
\begin{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1560
  \begin{axis}[
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1561
    xlabel={$n$},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1562
    x label style={at={(1.05,0.0)}},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1563
    ylabel={time in secs},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1564
    enlargelimits=false,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1565
    xtick={0,5,...,30},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1566
    xmax=33,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1567
    ymax=35,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1568
    ytick={0,10,...,30},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1569
    scaled ticks=false,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1570
    axis lines=left,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1571
    width=9cm,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1572
    height=5.5cm, 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1573
    legend entries={Java 8, Python, JavaScript, Swift},  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1574
    legend pos=north west,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1575
    legend cell align=left]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1576
\addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1577
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1578
\addplot[red,mark=*, mark options={fill=white}] table {re-js.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1579
\addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1580
\end{axis}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1581
\end{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1582
\end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1583
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1584
Regex: \bl{$(a^*)^* \cdot b$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1585
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1586
Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1587
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1588
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1589
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1590
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1591
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1592
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1593
\frametitle{Same Example in Java 9+}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1594
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1595
\begin{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1596
\begin{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1597
  \begin{axis}[
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1598
    xlabel={$n$},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1599
    x label style={at={(1.09,-0.15)}},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1600
    ylabel={time in secs},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1601
    scaled x ticks=false,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1602
    enlargelimits=false,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1603
    xtick distance=10000,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1604
    xmax=44000, 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1605
    ytick={0,10,...,30}, 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1606
    ymax=35, 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1607
    axis lines=left,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1608
    width=9cm,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1609
    height=5cm, 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1610
    legend entries={Java \liningnums{9}+},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1611
    legend pos=north west,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1612
    legend cell align=left]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1613
\addplot[blue,mark=square*,mark options={fill=white}] table {re-java9.data};
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1614
\end{axis}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1615
\end{tikzpicture}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1616
\end{center}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1617
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1618
Regex: \bl{$(a^*)^* \cdot b$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1619
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1620
Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1621
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1622
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1623
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1624
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1625
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1626
% Questions
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1627
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1628
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1629
\begin{mybox3}{}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1630
  Are there any (common) languages that have a built-in regex
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1631
  implementation matching the set of functions of a formal 'simple'
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1632
  regular expression, as opposed to an 'extended' regular expression
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1633
  implemented in most regex-supporting languages?
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1634
\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1635
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1636
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1637
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1638
\begin{mybox3}{Regexes}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1639
  Can we determine all the possible regular expressions matching a
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1640
  certain string? If we take into account all the possible ways to
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1641
  combine the operations: \bl{$\ZERO$}, \bl{$\ONE$},
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1642
  \bl{$r_1 + r_2$}, \bl{$r_1 \cdot r_2$}, \bl{$r^*$}?
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1643
\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1644
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1645
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1646
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1647
\begin{mybox3}{\bl{$L$} + Equivalence}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1648
  When we explain why two regular expressions are not equivalent, what
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1649
  method is better for us, using mathematics formulas or making an
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1650
  example? 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1651
\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1652
\begin{mybox3}{}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1653
  Meaning of Regex and Operations
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1654
\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1655
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1656
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1657
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1658
\begin{mybox3}{\bl{$L$}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1659
  Can the function L be applied to anything other than regular
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1660
  expressions? For example would L(L(c)) return anything?
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1661
\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1662
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1663
\hfill $\Rightarrow$ No
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1664
\end{frame} 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1665
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1666
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1667
\begin{mybox3}{\bl{$(a?)\{n\} \cdot a\{n\}$}}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1668
  In the evil regexes section, is there any reason why in the regex
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1669
  \texttt{[a?]\{n\}[a]\{n\}} the square brackets are used? It is defined as a
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1670
  single character from the square brackets, however there is just one
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1671
  character, so it seems like it is not necessary. Maybe it is just
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1672
  necessary for the first part, because ? is a token instead of a
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1673
  character and we need to refer to a? as a ``unit''? Could regular
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1674
  brackets be used instead? Is there any difference apart from the
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1675
  fact that it would create a group? Also, are the regexes
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1676
  \texttt{[a?]\{n\}} and
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1677
  \texttt{a\{0,3\}} equivalent?
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1678
\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1679
\end{frame} 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1680
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1681
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1682
\begin{mybox3}{Python + Parser Combinators (CW3)}\small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1683
  Hi Christian,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1684
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1685
  I don’t see a problem: you certainly have higher order functions and
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1686
  it is easy to implement algebraic data types using classes. As far
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1687
  as I can see that’s all you need. You don’t get the static types but
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1688
  that should be obvious. Basically if you can do it in LISP you can
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1689
  do it in Python. The only problem could be stack overflows due to a
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1690
  lack of tail recursion optimisation. On the other hand you can
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1691
  simulate laziness using generators.
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1692
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1693
  Cheers,
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1694
  Thorsten 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1695
\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1696
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1697
Trees \url{https://youtu.be/7tCNu4CnjVc}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1698
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1699
Laziness \url{https://youtu.be/5jwV3zxXc8E}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1700
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1701
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1702
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1703
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1704
\begin{mybox3}{}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1705
  What suggestions do you have for us to get the most out of this
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1706
  module, especially in the online format? I.e. form discussion
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1707
  groups, will you have office hours?
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1708
\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1709
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1710
\small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1711
\hfill $\Rightarrow$\mbox{} Discussion Forum on KEATS
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1712
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1713
\hfill online tutorial sessions
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1714
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1715
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1716
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1717
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1718
 \small
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1719
\begin{mybox3}{}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1720
Where do most students struggle with this module? What will the format
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1721
of the exam be? What is the most efficient way of studying for the
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1722
exam? There are plenty of resources available on KEATS, but is there
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1723
anything else you'd recommend us to study? Although (just by skimming
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1724
the headings) the module seems to be a combination of practical and
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1725
theoretical matters, exactly in what field would the syllabus be
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1726
applied? Besides these questions and the ones other students asked, is
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1727
there anything else we should know? Thank you!
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1728
\end{mybox3}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1729
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1730
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1731
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1732
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1733
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1734
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1735
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1736
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1737
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1738
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1739
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1740
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1741
\begin{frame}[c]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1742
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1743
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1744
\begin{frame}[c,fragile]
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1745
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1746
\end{frame}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1747
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1748
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1749
\end{document}
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1750
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1751
%%% Local Variables:  
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1752
%%% mode: latex
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1753
%%% TeX-master: t
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1754
%%% End: 
771396fa6cc4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
  1755