Slides/slides04.tex
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 24 Aug 2016 10:37:40 +0100
changeset 208 02568e85a394
parent 207 599b2bfcebf6
child 209 c592ea0661ae
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
\documentclass{beamer}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
\usepackage{tikz}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
\usepackage[english]{babel}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
\usepackage{proof}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
\usetheme{Luebeck}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
\usetikzlibrary{positioning}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
\usetikzlibrary{decorations.pathreplacing}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
\definecolor{darkblue}{rgb}{0,0,.803}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
\definecolor{cream}{rgb}{1,1,.8}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
\newcommand{\smath}[1]{\textcolor{darkblue}{\ensuremath{#1}}}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
\newcommand{\Zero}{{\bf 0}}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
\newcommand{\One}{{\bf 1}}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
\newenvironment{bubble}[1][]{%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
\addtolength{\leftmargini}{4mm}%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
\begin{tikzpicture}[baseline=(current bounding box.north)]%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
\draw (0,0) node[inner sep=2mm,fill=cream,ultra thick,draw=red,rounded corners=2mm]% 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
\bgroup\begin{minipage}{#1}\raggedright{}}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
{\end{minipage}\egroup;%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
\end{tikzpicture}\bigskip}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
    24
\title{\bf POSIX Lexing with\\ 
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
       \bf Derivatives of Regular Expressions\\
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
       \bf (Proof Pearl)}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    27
\author{Fahad Ausaf, Roy Dyckhoff and Christian Urban}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
\date{King's College London, University of St Andrews}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
\begin{document}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
\maketitle
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
	\begin{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
	\frametitle{Brzozowski's Derivatives of Regular Expressions}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
		
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
	Idea: If \smath{r} matches the string \smath{c\!::\!s}, 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
	what is a regular expression that matches just \smath{s}? \\
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
		
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    41
   \begin{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    42
   \begin{tabular}{l@{\hspace{5mm}}lcl}	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
   chars:
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
   &\smath{\Zero \backslash c} & \smath{\dn} & \smath{\Zero}\\
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
   &\smath{\One \backslash c}  & \smath{\dn} & \smath{\Zero}\\
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
   &\smath{d \backslash c}  & \smath{\dn} & 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
   \smath{\textit{if}\;d = c\;\textit{then}\;\One\;\textit{else}\;\Zero}\\
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
   &\smath{r_1 + r_2 \backslash c} & \smath{\dn} & 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
   \smath{r_1 \backslash c \,+\, r_2 \backslash c}\\
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
   &\smath{r_1 \cdot r_2 \backslash c} & \smath{\dn} & 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
   \smath{\textit{if}\;\textit{nullable}\;r_1}\\
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
   && & \smath{\textit{then}\;r_1\backslash c \cdot r_2 \,+\, r_2\backslash c
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
   \;\textit{else}\;r_1\backslash c \cdot r_2}\\
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
   &\smath{r^* \backslash c} & \smath{\dn} & 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    55
   \smath{r\backslash c \,\cdot\, r^*}\bigskip\\
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
   
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
   strings:
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
   &\smath{r\backslash []} & \smath{\dn} & \smath{r}\\  
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
   &\smath{r\backslash c\!::\!s} & \smath{\dn} & 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
   \smath{(r\backslash c)\backslash s}\\
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    61
   \end{tabular}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
   \end{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
	\end{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
	\begin{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
	\frametitle{Brzozowski's Matcher}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    69
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
	Does \smath{r_1} match string \smath{abc}? 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
	\begin{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    73
	\begin{tikzpicture}[scale=2,node distance=1.3cm,every node/.style={minimum size=8mm}]
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
		\node (r1)  {\smath{r_1}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
		\node (r2) [right=of r1] {\smath{r_2}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
		\draw[->,line width=1mm]  (r1) -- (r2) node[above,midway] {\smath{\_\backslash a}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
		\node (r3) [right=of r2] {\smath{r_3}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
		\draw[->,line width=1mm]  (r2) -- (r3) node[above,midway] {\smath{\_\backslash b}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
		\node (r4) [right=of r3] {\smath{r_4}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
		\draw[->,line width=1mm]  (r3) -- (r4) node[above,midway] {\smath{\_\backslash c}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    81
		\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\smath{\;\;\textit{nullable}?}}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
	\end{tikzpicture}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    83
	\end{center}\pause
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    84
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    85
	It leads to an elegant functional program:
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    86
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    87
	\begin{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    88
	\smath{\textit{matches}\,(r, s) \dn \textit{nullable}\,(r\backslash s)}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    89
	\end{center}\pause
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    90
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    91
	It is an easy exercise to formally prove (e.g.~Coq, HOL, Isabelle):
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    92
		
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    93
	\begin{center}	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    94
		\smath{\textit{matches}\,(r, s)} if and only if 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    95
		\smath{s \in L(r)}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    96
   \end{center}\pause 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    97
		
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
	{\bf But Brzozowski's matcher gives only a yes/no-answer.}	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    99
	\end{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   100
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   101
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
	
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   103
%	\begin{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   104
%		\frametitle{Sulzmann and Lu's Matcher}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   105
%		\begin{itemize}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   106
%			\item Sulzmann \& Lu came up with a beautiful idea for how 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   107
%			to extend the simple regular expression matcher to POSIX 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   108
%			matching/lexing (FLOPS 2014)
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   109
%			\item The idea: define an inverse operation to the derivatives
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   110
%		\end{itemize}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   111
%	\end{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   112
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   113
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   114
	
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   115
	\begin{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   116
	\frametitle{Sulzmann and Lu's Matcher}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   117
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   118
   Sulzmann and Lu added a second phase in order to answer
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   119
   \alert{\textbf{how}} the regular expression matched the string.
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   120
   
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   121
   \begin{center}\small
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   122
   \begin{tikzpicture}[scale=1,node distance=0.8cm,every node/.style={minimum size=7mm}]
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   123
		\node (r1)  {\smath{r_1}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   124
		\node (r2) [right=of r1] {\smath{r_2}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   125
		\draw[->,line width=1mm]  (r1) -- (r2) node[above,midway] {\smath{\_\backslash a}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   126
		\node (r3) [right=of r2] {\smath{r_3}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   127
		\draw[->,line width=1mm]  (r2) -- (r3) node[above,midway] {\smath{\_\backslash b}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   128
		\node (r4) [right=of r3] {\smath{r_4}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   129
		\draw[->,line width=1mm]  (r3) -- (r4) node[above,midway] {\smath{\_\backslash c}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   130
		\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\smath{\;\;nullable?}}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   131
		\node (v4) [below=of r4] {\smath{v_4}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   132
		\draw[->,line width=1mm]  (r4) -- (v4);
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   133
		\node (v3) [left=of v4] {\smath{v_3}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   134
		\draw[->,line width=1mm]  (v4) -- (v3) node[below,midway] {\smath{inj\,c}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   135
		\node (v2) [left=of v3] {\smath{v_2}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   136
		\draw[->,line width=1mm]  (v3) -- (v2) node[below,midway] {\smath{inj\,b}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   137
		\node (v1) [left=of v2] {\smath{v_1}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   138
		\draw[->,line width=1mm]  (v2) -- (v1) node[below,midway] {\smath{inj\,a}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   139
		\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\smath{mkeps}}};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   140
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
       \draw [decorate,decoration={brace,amplitude=10pt,raise=8mm},
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   142
              line width=1.5mm]
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   143
              (r1) -- (r4) node [black,midway,above, yshift=12mm] 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   144
             {\large\bf  first phase};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   145
       \draw [decorate,decoration={brace,amplitude=10pt,raise=8mm},
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   146
              line width=1.5mm]
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   147
              (v4) -- (v1) node [black,midway,below, yshift=-12mm] 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   148
             {\large\bf  second phase}; 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   149
       %% first phase      
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   150
       \draw[line width=14mm, rounded corners, opacity=0.1,
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   151
             cap=round,join=round,color=yellow!30]
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   152
            (r1.center)  -- (r4.center);
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   153
       %% second phase     
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   154
       \draw[line width=14.1mm, rounded corners, opacity=0.2,
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   155
             cap=round,join=round,draw=black, fill=white]
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   156
            (r4)  -- (v4.center) -- (v1.center);
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   157
       \draw[line width=14mm, rounded corners, opacity=0.2,
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   158
             cap=round,join=round,color=yellow!30]
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   159
            (r4)  -- (v4.center) -- (v1.center);     
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   160
	\end{tikzpicture}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   161
   \end{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   162
   
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   163
   There are several possible answers for 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   164
   \alert{\textbf{how}}: POSIX, GREEDY, \ldots
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   165
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   166
   \end{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   167
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   168
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   169
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   170
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   171
	\begin{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   172
	\frametitle{POSIX Matching (needed for Lexing)}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   173
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   174
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   175
    \begin{bubble}[10cm]
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   176
    {\bf Longest Match Rule:} The longest 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   177
    initial substring matched by any regular expression is taken 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   178
    as the next token.
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   179
    \end{bubble}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   180
    
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   181
    \begin{bubble}[10cm]
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   182
    {\bf Rule Priority:} For a particular longest initial substring, 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   183
    the first regular expression that can match determines the 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   184
	token.
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   185
    \end{bubble}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   186
  
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   187
	For example: \smath{r_{keywords} + r_{identifiers}} (fix graphics below)
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   188
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   189
		\begin{center}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   190
		\texttt{iffoo\_bla} 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   191
		\end{center}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   192
		
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   193
		\begin{center}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   194
		\texttt{if\_bla} 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   195
		\end{center}	
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   196
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   197
	\end{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   198
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   199
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   200
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   201
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   202
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   203
	\begin{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   204
	\frametitle{Problems with POSIX}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   205
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   206
	Grathwohl, Henglein and Rasmussen wrote:
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   207
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   208
	\begin{bubble}[10cm]   
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   209
	\it ``The POSIX strategy is more complicated than the greedy because 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   210
	of the dependence on information 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   211
	about the length of matched strings in the various subexpressions.''   
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   212
	\end{bubble}\bigskip   
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   213
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   214
	Also Kuklewicz maintains a unit-test repository for POSIX
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   215
	matching, which indicates that most POSIX mathcers are buggy.
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   216
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   217
	\begin{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   218
	\url{http://www.haskell.org/haskellwiki/Regex_Posix}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   219
   \end{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   220
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   221
	\end{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   222
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   223
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   224
	
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   225
%	\begin{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   226
%	\frametitle{Correctness}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   227
%	\begin{itemize}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   228
%		\item Sulzmann \& Lu came up with a beautiful idea for how 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   229
%		to extend the simple regular expression matcher to POSIX 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   230
%		matching/lexing (FLOPS 2014)
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   231
%		\item The idea: define an inverse operation to the derivatives
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   232
%	\end{itemize}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   233
%	\end{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   234
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   235
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   236
	
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   237
	\begin{frame}
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   238
	\frametitle{Regular Expressions and Values}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   239
	Regular expressions and their corresponding values (for how a 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   240
	regular expression matched string): 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   241
    \begin{columns}[c] % the "c" option specifies center vertical alignment
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   242
    \column{.5\textwidth} % column designated by a command
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   243
     	\begin{tabular}{ l l l }
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   244
			$r$ & ::= 		& $\varnothing$ 	\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   245
			    & $\mid$	& $\epsilon$ 		\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   246
			    & $\mid$	& $c$ 				\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   247
			    & $\mid$	& $r_1 \cdot r_2$	\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   248
			    & $\mid$	& $r_1 + r_2$		\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   249
			    & $\mid$	& $r^*$				\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   250
		\end{tabular}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   251
    \column{.5\textwidth}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   252
     	\begin{tabular}{ l l l }
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   253
			$v$ & ::= 		& $\varnothing$ 	\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   254
			    & $\mid$	& $Empty$ 			\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   255
			    & $\mid$	& $Char$($c$) 		\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   256
			    & $\mid$	& $Seq$($v_1.v_2$)	\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   257
			    & $\mid$	& $Left$($v$)		\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   258
			    & $\mid$	& $Right$($v$)		\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   259
			    & $\mid$	& []				\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   260
			    & $\mid$	& [$v_1,...,v_n$]
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   261
		\end{tabular}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   262
    \end{columns}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   263
    There is also a notion of a string behind a value $\mid v \mid$
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   264
	\end{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   265
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   266
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   267
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   268
	\begin{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   269
	\frametitle{Sulzmann and Lu Matcher}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   270
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   271
	We want to match the string $abc$ using $r_1$\\
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   272
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   273
	\begin{center}	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   274
	\begin{tikzpicture}[scale=2,node distance=1.3cm,every node/.style={minimum size=8mm}]
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   275
		\node (r1)  {$r_1$};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   276
		\node (r2) [right=of r1] {$r_2$};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   277
		\draw[->,line width=1mm]  (r1) -- (r2) node[above,midway] {$der\,a$};\pause
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   278
		\node (r3) [right=of r2] {$r_3$};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   279
		\draw[->,line width=1mm]  (r2) -- (r3) node[above,midway] {$der\,b$};\pause
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   280
		\node (r4) [right=of r3] {$r_4$};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   281
		\draw[->,line width=1mm]  (r3) -- (r4) node[above,midway] {$der\,c$};\pause
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   282
		\draw (r4) node[anchor=west] {\;\raisebox{3mm}{$\;\;nullable?$}};\pause
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   283
		\node (v4) [below=of r4] {$v_4$};
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   284
		\draw[->,line width=1mm]  (r4) -- (v4);
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   285
		\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{$mkeps$}};\pause
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   286
		\node (v3) [left=of v4] {$v_3$};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   287
		\draw[->,line width=1mm]  (v4) -- (v3) node[below,midway] {$inj\,c$};\pause
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   288
		\node (v2) [left=of v3] {$v_2$};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   289
		\draw[->,line width=1mm]  (v3) -- (v2) node[below,midway] {$inj\,b$};\pause
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   290
		\node (v1) [left=of v2] {$v_1$};
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   291
		\draw[->,line width=1mm]  (v2) -- (v1) node[below,midway] {$inj\,a$};\pause
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   292
		\draw[->,line width=0.5mm]  (r3) -- (v3);
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   293
		\draw[->,line width=0.5mm]  (r2) -- (v2);
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   294
		\draw[->,line width=0.5mm]  (r1) -- (v1);
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   295
	\end{tikzpicture}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   296
	\end{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   297
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   298
	\end{frame}	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   299
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   300
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   301
	
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   302
	\begin{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   303
	\frametitle{Nullable, Mkeps and Injection Functions}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   304
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   305
	\textbf{Nullable Function}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   306
	\begin{tabular}{ l l l }
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   307
		\textit{nullable} (\textbf{0}) & $\dn$ & \textit{False}\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   308
		\textit{nullable} (\textbf{1}) & $\dn$ & \textit{True}\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   309
		\textit{nullable} (c) & $\dn$ & \textit{False}\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   310
		\textit{nullable} ($r_1 + r_2$) & $\dn$ & \textit{nullable} $r_1$ $\lor$ \textit{nullable} $r_2$\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   311
		\textit{nullable} ($r_1 \cdot r_2$) & $\dn$ & \textit{nullable} $r_1$ $\land$ \textit{nullable} $r_2$\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   312
		\textit{nullable} ($r^*$) & $\dn$ & \textit{True}\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   313
	\end{tabular}\\	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   314
	\vspace{3 mm}	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   315
	\textbf{Mkeps Function}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   316
	\begin{tabular}{ l l l }
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   317
		\textit{mkeps} (\textbf{1}) 		& $\dn$ & () 	\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   318
		\textit{mkeps} ($r_1 \cdot r_2$) 	& $\dn$	& \textit{Seq} (\textit{mkeps} $r_1$) (\textit{mkeps} $r_2$)\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   319
		\textit{mkeps} ($r_1 + r_2$) 		& $\dn$	& \textit{if nullable $r_1$ then Left} (\textit{mkeps $r_1$})\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   320
											& 		& \textit{else Right} (\textit{mkeps $r_2$})\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   321
		\textit{mkeps} ($r^*$) 				& $\dn$	& \textit{Stars} []	\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   322
	\end{tabular}\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   323
				
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   324
	\end{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   325
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   326
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   327
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   328
	\begin{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   329
	\frametitle{Nullable, Mkeps and Injection Functions}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   330
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   331
	\textbf{Injection Function}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   332
	\begin{tabular}{ l l l }
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   333
		\textit{inj d c} () & $\dn$ & \textit{Char d}\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   334
		\textit{inj} ($r_1 + r_2$) \textit{c} (\textit{Left $v_1$}) & $\dn$ & \textit{Left} (\textit{inj $r_1$ c $v_1$})\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   335
		\textit{inj} ($r_1 + r_2$) \textit{c} (\textit{Right $v_2$}) & $\dn$ & \textit{Right} (\textit{inj $r_2$ c $v_2$})\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   336
		\textit{inj} ($r_1 \cdot r_2$) \textit{c} (\textit{Seq $v_1$ $v_2$}) & $\dn$ & \textit{Seq} (\textit{inj $r_1$ c $v_1$}) $v_2$\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   337
		\textit{inj} ($r_1 \cdot r_2$) \textit{c} (\textit{Left} (\textit{Seq $v_1$ $v_2$})) & $\dn$ & \textit{Seq} (\textit{inj $r_1$ c $v_1$}) $v_2$\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   338
		\textit{inj} ($r_1 \cdot r_2$) \textit{c} (\textit{Right $v_2$}) & $\dn$ & \textit{Seq} (\textit{mkeps $r_1$}) (\textit{inj $r_2$ c $v_2$})\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   339
		\textit{inj} ($r^*$) \textit{c} (\textit{Seq v} (\textit{Stars vs})) & $\dn$ & \textit{Stars} (\textit{inj r c v}::\textit{vs})
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   340
	\end{tabular}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   341
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   342
	\end{frame}	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   343
		
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   344
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   345
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   346
	\begin{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   347
	\frametitle{POSIX Ordering Relation by Sulzmann \& Lu}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   348
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   349
	\begin{itemize}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   350
	\item Introduce an inductive defined ordering relation 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   351
	$v \succ_r v'$ which captures the idea of POSIX matching.
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   352
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   353
	\item The algorithm returns the maximum of all possible values 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   354
	that are possible for a regular expression.
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   355
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   356
	\item The idea is from a paper by Frisch \& Cardelli about 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   357
	GREEDY matching (GREEDY = preferring instant gratification 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   358
	to delayed repletion):
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   359
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   360
	\item e.g. given $(a + (b + ab))^{*}$ and string $ab$\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   361
	\begin{center}	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   362
	\begin{tabular}{ll}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   363
	GREEDY: & $[Left(a), Right(Left(b))]$\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   364
	POSIX: 	& $[Right(Right(Seq(a, b)))]$
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   365
	\end{tabular}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   366
	\end{center}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   367
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   368
	\end{itemize}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   369
	\end{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   370
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   371
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   372
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   373
	\begin{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   374
	\frametitle{POSIX Ordering Relation by Sulzmann \& Lu}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   375
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   376
	\begin{center}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   377
		$\infer{\vdash Empty : \epsilon}{}$\hspace{15mm}	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   378
		$\infer{\vdash Char(c): c}{}$\bigskip
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   379
		
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   380
		$\infer{\vdash Seq(v_1, v_2) : r_1\cdot r_2}{\vdash v_1 : r_1 \quad \vdash v_2 : r_2}$
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   381
		\bigskip
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   382
		
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   383
		$\infer{\vdash Left(v) : r_1 + r_2}{\vdash v : r_1}$\hspace{15mm}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   384
		$\infer{\vdash Right(v): r_1 + r_2}{\vdash v : r_2}$\bigskip
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   385
		
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   386
		$\infer{\vdash [] : r^*}{}$\hspace{15mm}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   387
		$\infer{\vdash [v_1,\ldots, v_n] : r^*}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   388
		{\vdash v_1 : r \quad\ldots\quad \vdash v_n : r}$
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   389
	\end{center}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   390
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   391
	\end{frame}
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   392
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   393
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   394
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   395
	\begin{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   396
	\frametitle{Problems}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   397
	\begin{itemize}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   398
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   399
	\item Sulzmann: \ldots Let's assume $v$ is not a $POSIX$ value, 
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   400
	then there must be another one \ldots contradiction.
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   401
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   402
	\item Exists ?
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   403
	\begin{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   404
	$L(r) \not= \varnothing \;\Rightarrow\; \exists v.\;POSIX(v, r)$
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   405
	\end{center}
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   406
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   407
	\item In the sequence case 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   408
	$Seq(v_1,v_2)\succ_{r_1\cdot r_2} Seq(v_1', v_2')$, 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   409
	the induction hypotheses require 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   410
	$|v_1| = |v_1'|$ and $|v_2| = |v_2'|$, but you only know 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   411
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   412
	\begin{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   413
	$|v_1| @ |v_2| = |v_1'| @ |v_2'|$
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   414
	\end{center}
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   415
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   416
	\item Although one begins with the assumption that the two 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   417
	values have the same flattening, this cannot be maintained 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   418
	as one descends into the induction (alternative, sequence)
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   419
		
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   420
	\end{itemize}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   421
	\end{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   422
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   423
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   424
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   425
	\begin{frame}
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   426
		\frametitle{Problems}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   427
		
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   428
		\begin{itemize}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   429
			\item I have no doubt the algorithm is correct --- 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   430
			the problem is I do not believe their proof.
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   431
			
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   432
			\begin{center}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   433
				\small
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   434
				``How could I miss this? Well, I was rather careless when 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   435
				stating this Lemma :)\smallskip
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   436
				
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   437
				Great example how formal machine checked proofs (and 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   438
				proof assistants) can help to spot flawed reasoning steps.''
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   439
				
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   440
			\end{center}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   441
			
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   442
			\begin{center}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   443
				\small
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   444
				``Well, I don't think there's any flaw. The issue is how to 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   445
				come up with a mechanical proof. In my world mathematical 
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   446
				proof $=$ mechanical proof doesn't necessarily hold.''
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   447
				
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   448
			\end{center}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   449
			
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   450
		\end{itemize}	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   451
		
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   452
	\end{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   453
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   454
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   455
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   456
	\begin{frame}
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   457
	\frametitle{Our Solution}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   458
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   459
	\begin{itemize}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   460
	\item A direct definition of what a POSIX value is, using the 
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   461
	relation $s \in r \to v$ (specification)
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   462
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   463
	\begin{center}
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   464
		$\infer{[] \in \epsilon \to Empty}{}$\hspace{15mm}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   465
		$\infer{c \in c \to Char(c)}{}$\bigskip\medskip
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   466
		
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   467
		$\infer{s \in r_1 + r_2 \to Left(v)}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   468
		{s \in r_1 \to v}$\hspace{10mm}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   469
		$\infer{s \in r_1 + r_2 \to Right(v)}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   470
		{s \in r_2 \to v & s \not\in L(r_1)}$\bigskip\medskip
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   471
		
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   472
		$\infer{s_1 @ s_2 \in r_1 \cdot r_2 \to Seq(v_1, v_2)}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   473
		{\small\begin{array}{l}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   474
			s_1 \in r_1 \to v_1 \\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   475
			s_2 \in r_2 \to v_2 \\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   476
			\neg(\exists s_3\,s_4.\; s_3 \not= []
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   477
			\wedge s_3 @ s_4 = s_2 \wedge
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   478
			s_1 @ s_3 \in L(r_1) \wedge
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   479
			s_4 \in L(r_2))
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   480
			\end{array}}$
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   481
		\\
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   482
		\bigskip
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   483
		...
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   484
	\end{center}	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   485
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   486
	\end{itemize}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   487
	\end{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   488
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   489
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   490
	\begin{frame}[c]
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   491
	\frametitle{Properties}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   492
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   493
	It is almost trival to prove:
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   494
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   495
	\begin{itemize}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   496
	\item Uniqueness
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   497
	\begin{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   498
	If $s \in r \to v_1$ and $s \in r \to v_2$ then
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   499
	$v_1 = v_2$
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   500
	\end{center}\bigskip
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   501
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   502
	\item Correctness
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   503
	\begin{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   504
	$lexer(r, s) = v$ if and only if $s \in r \to v$
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   505
	\end{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   506
	\end{itemize}\bigskip\bigskip\pause
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   507
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   508
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   509
	You can now start to implement optimisations and derive
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   510
	correctness proofs for them. But we still do not know whether
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   511
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   512
	\begin{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   513
	$s \in r \to v$ 
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   514
	\end{center}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   515
	
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   516
	is a POSIX value according to Sulzmann \& Lu's definition
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   517
	(biggest value for $s$ and $r$)
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   518
	\end{frame}
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   519
	
208
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   520
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   521
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   522
	\begin{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   523
		\frametitle{Conclusions}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   524
		
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   525
		\begin{itemize}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   526
			
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   527
			\item We replaced the POSIX definition of Sulzmann \& Lu by a
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   528
			new definition (ours is inspired by work of Vansummeren,
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   529
			2006)\medskip
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   530
			
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   531
			\item Their proof contained small gaps (acknowledged) but had
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   532
			also fundamental flaws\medskip
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   533
			
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   534
			\item Now, its a nice exercise for theorem proving\medskip
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   535
			
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   536
			\item Some optimisations need to be applied to the algorithm
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   537
			in order to become fast enough\medskip
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   538
			
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   539
			\item Can be used for lexing, is a small beautiful functional
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   540
			program
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   541
			
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   542
		\end{itemize}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   543
	\end{frame}
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   544
	
02568e85a394 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 207
diff changeset
   545
	
207
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   546
599b2bfcebf6 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   547
\end{document}