author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Sat, 20 Aug 2016 13:39:19 +0100 | |
changeset 207 | 599b2bfcebf6 |
child 208 | 02568e85a394 |
permissions | -rw-r--r-- |
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 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
\newcommand\grid[1]{% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
\begin{tikzpicture}[baseline=(char.base)] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
\path[use as bounding box] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
27 |
(0,0) rectangle (1em,1em); |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
\draw[red!50, fill=red!20] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
29 |
(0,0) rectangle (1em,1em); |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
30 |
\node[inner sep=1pt,anchor=base west] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
31 |
(char) at (0em,\gridraiseamount) {#1}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
\end{tikzpicture}} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
\newcommand\gridraiseamount{0.12em} |
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 |
\makeatletter |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
36 |
\newcommand\Grid[1]{% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
\@tfor\z:=#1\do{\grid{\z}}} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
38 |
\makeatother |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
39 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
40 |
\newcommand\Vspace[1][.3em]{% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
41 |
\mbox{\kern.06em\vrule height.3ex}% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
42 |
\vbox{\hrule width#1}% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
43 |
\hbox{\vrule height.3ex}} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
44 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
\def\VS{\Vspace[0.6em]} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
48 |
\title[POSIX Lexing with Derivatives of Regexes] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
49 |
{\bf POSIX Lexing with\\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
50 |
\bf Derivatives of Regular Expressions\\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
51 |
\bf (Proof Pearl)} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
52 |
\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
|
53 |
\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
|
54 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
55 |
\begin{document} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
56 |
\maketitle |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
57 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
58 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
59 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
60 |
\begin{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
61 |
\frametitle{Brzozowski's Derivatives of Regular Expressions} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
62 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
63 |
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
|
64 |
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
|
65 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
66 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
67 |
\begin{tabular}{l@{\hspace{5mm}}lcl} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
68 |
chars: |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
69 |
&\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
|
70 |
&\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
|
71 |
&\smath{d \backslash c} & \smath{\dn} & |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
72 |
\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
|
73 |
&\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
|
74 |
\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
|
75 |
&\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
|
76 |
\smath{\textit{if}\;\textit{nullable}\;r_1}\\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
77 |
&& & \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
|
78 |
\;\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
|
79 |
&\smath{r^* \backslash c} & \smath{\dn} & |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
80 |
\smath{r\backslash c \,\cdot\, r^*}\bigskip\\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
81 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
82 |
strings: |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
83 |
&\smath{r\backslash []} & \smath{\dn} & \smath{r}\\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
84 |
&\smath{r\backslash c\!::\!s} & \smath{\dn} & |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
85 |
\smath{(r\backslash c)\backslash s}\\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
86 |
\end{tabular} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
87 |
\end{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
88 |
\end{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
89 |
|
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 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
92 |
\begin{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
93 |
\frametitle{Brzozowski's Matcher} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
94 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
95 |
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
|
96 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
97 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
98 |
\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
|
99 |
\node (r1) {\smath{r_1}}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
100 |
\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
|
101 |
\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
|
102 |
\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
|
103 |
\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
|
104 |
\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
|
105 |
\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
|
106 |
\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
|
107 |
\end{tikzpicture} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
108 |
\end{center}\pause |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
109 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
110 |
It leads to an elegant functional program: |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
111 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
112 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
113 |
\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
|
114 |
\end{center}\pause |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
115 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
116 |
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
|
117 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
118 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
119 |
\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
|
120 |
\smath{s \in L(r)} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
121 |
\end{center}\pause |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
122 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
123 |
{\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
|
124 |
\end{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
125 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
126 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
127 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
128 |
\begin{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
129 |
\frametitle{Sulzmann and Lu's Matcher} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
130 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
131 |
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
|
132 |
\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
|
133 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
134 |
\begin{center}\small |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
135 |
\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
|
136 |
\node (r1) {\smath{r_1}}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
137 |
\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
|
138 |
\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
|
139 |
\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
|
140 |
\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
|
141 |
\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
|
142 |
\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
|
143 |
\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
|
144 |
\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
|
145 |
\draw[->,line width=1mm] (r4) -- (v4); |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
146 |
\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
|
147 |
\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
|
148 |
\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
|
149 |
\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
|
150 |
\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
|
151 |
\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
|
152 |
\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
|
153 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
154 |
\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
|
155 |
line width=1.5mm] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
156 |
(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
|
157 |
{\large\bf first phase}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
158 |
\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
|
159 |
line width=1.5mm] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
160 |
(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
|
161 |
{\large\bf second phase}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
162 |
%% first phase |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
163 |
\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
|
164 |
cap=round,join=round,color=yellow!30] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
165 |
(r1.center) -- (r4.center); |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
166 |
%% second phase |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
167 |
\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
|
168 |
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
|
169 |
(r4) -- (v4.center) -- (v1.center); |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
170 |
\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
|
171 |
cap=round,join=round,color=yellow!30] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
172 |
(r4) -- (v4.center) -- (v1.center); |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
173 |
\end{tikzpicture} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
174 |
\end{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
175 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
176 |
There are several possible answers for |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
177 |
\alert{\textbf{how}}: POSIX, GREEDY, \ldots |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
178 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
179 |
\end{frame} |
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 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
182 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
183 |
\begin{frame}{Regular Expressions and Values} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
184 |
Regular expressions and their corresponding values (for how a |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
185 |
regular expression matched a string):\bigskip |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
186 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
187 |
\begin{columns}[c] % the "c" option specifies center vertical alignment |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
188 |
\column{.4\textwidth} % column designated by a command |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
189 |
\begin{tabular}{ l l l } |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
190 |
\smath{r} & ::= & \smath{\Zero} \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
191 |
& $\mid$ & \smath{\One} \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
192 |
& $\mid$ & \smath{c} \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
193 |
& $\mid$ & \smath{r_1 \cdot r_2} \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
194 |
& $\mid$ & \smath{r_1 + r_2} \\ \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
195 |
& $\mid$ & \smath{r^*} \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
196 |
\end{tabular} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
197 |
\column{.4\textwidth} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
198 |
\begin{tabular}{ l l l } |
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 |
\smath{v} & ::= & \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
201 |
& $\mid$ & \smath{Empty} \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
202 |
& $\mid$ & \smath{Char(c)} \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
203 |
& $\mid$ & \smath{Seq(v_1\cdot v_2)} \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
204 |
& $\mid$ & \smath{Left(v)} \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
205 |
& $\mid$ & \smath{Right(v)} \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
206 |
& $\mid$ & \smath{[v_1,...,v_n]} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
207 |
\end{tabular} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
208 |
\end{columns} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
209 |
\end{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
210 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
211 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
212 |
|
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 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
215 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
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{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
218 |
\frametitle{POSIX Matching (needed for Lexing)} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
219 |
|
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 |
\begin{bubble}[10cm] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
222 |
{\bf Longest Match Rule:} The longest |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
223 |
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
|
224 |
as the next token. |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
225 |
\end{bubble} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
226 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
227 |
\begin{bubble}[10cm] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
228 |
{\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
|
229 |
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
|
230 |
token. |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
231 |
\end{bubble} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
232 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
233 |
For example: \smath{r_{keywords} + r_{identifiers}}:\bigskip |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
234 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
235 |
\begin{itemize} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
236 |
\item \smath{\texttt{\Grid{iffoo\VS bla}}} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
237 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
238 |
\item \smath{\texttt{\Grid{if\VS bla}}} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
239 |
\end{itemize} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
240 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
241 |
\end{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
242 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
243 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
244 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
245 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
246 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
247 |
\begin{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
248 |
\frametitle{Problems with POSIX} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
249 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
250 |
Grathwohl, Henglein and Rasmussen wrote: |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
251 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
252 |
\begin{bubble}[10cm] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
253 |
\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
|
254 |
of the dependence on information |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
255 |
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
|
256 |
\end{bubble}\bigskip |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
257 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
258 |
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
|
259 |
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
|
260 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
261 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
262 |
\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
|
263 |
\end{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
264 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
265 |
\end{frame} |
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 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
269 |
\begin{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
270 |
\frametitle{``Correctness'' by Sulzmann and Lu} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
271 |
\begin{itemize} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
272 |
\item Sulzmann \& Lu's idea is to order all possible |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
273 |
answer such that they can prove the correct answer is |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
274 |
the maximum |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
275 |
\item The idea is taken from a GREEDY algorithm (and it |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
276 |
works there)\bigskip\pause |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
277 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
278 |
\item {\bf But} we made no progress in formalising |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
279 |
Sulzmann \& Lu's idea, because |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
280 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
281 |
\begin{itemize} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
282 |
\item transitivity, existence of maxima etc all fail to |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
283 |
turn into real proofs |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
284 |
\item the reason: the ordering works only if .... |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
285 |
\item though we did find mistakes: |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
286 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
287 |
\small |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
288 |
``How could I miss this? Well, I was rather careless when |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
289 |
stating this Lemma :)\smallskip |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
290 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
291 |
Great example how formal machine checked proofs (and |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
292 |
proof assistants) can help to spot flawed reasoning steps.'' |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
293 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
294 |
\end{center}\pause |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
295 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
296 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
297 |
\small |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
298 |
``Well, I don't think there's any flaw. The issue is how to |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
299 |
come up with a mechanical proof. In my world mathematical |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
300 |
proof $=$ mechanical proof doesn't necessarily hold.'' |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
301 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
302 |
\end{center}\pause |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
303 |
\end{itemize} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
304 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
305 |
\end{itemize} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
306 |
\end{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
307 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
308 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
309 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
310 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
311 |
\begin{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
312 |
\frametitle{Sulzmann and Lu Matcher} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
313 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
314 |
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
|
315 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
316 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
317 |
\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
|
318 |
\node (r1) {$r_1$}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
319 |
\node (r2) [right=of r1] {$r_2$}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
320 |
\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
|
321 |
\node (r3) [right=of r2] {$r_3$}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
322 |
\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
|
323 |
\node (r4) [right=of r3] {$r_4$}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
324 |
\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
|
325 |
\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
|
326 |
\node (v4) [below=of r4] {$v_4$}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
327 |
\draw[->,line width=1mm] (r4) -- (v4);\pause |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
328 |
\node (v3) [left=of v4] {$v_3$}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
329 |
\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
|
330 |
\node (v2) [left=of v3] {$v_2$}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
331 |
\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
|
332 |
\node (v1) [left=of v2] {$v_1$}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
333 |
\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
|
334 |
\draw[->,line width=0.5mm] (r3) -- (v3); |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
335 |
\draw[->,line width=0.5mm] (r2) -- (v2); |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
336 |
\draw[->,line width=0.5mm] (r1) -- (v1); |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
337 |
\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{$mkeps$}}; |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
338 |
\end{tikzpicture} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
339 |
\end{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
340 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
341 |
\end{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
342 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
343 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
344 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
345 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
346 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
347 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
348 |
\begin{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
349 |
\frametitle{Problems} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
350 |
\begin{itemize} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
351 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
352 |
\item Sulzmann: \ldots Let's assume $v$ is not a $POSIX$ value, |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
353 |
then there must be another one \ldots contradiction.\pause |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
354 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
355 |
\item Exists ? |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
356 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
357 |
$L(r) \not= \varnothing \;\Rightarrow\; \exists v.\;POSIX(v, r)$ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
358 |
\end{center}\pause |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
359 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
360 |
\item In the sequence case |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
361 |
$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
|
362 |
the induction hypotheses require |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
363 |
$|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
|
364 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
365 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
366 |
$|v_1| @ |v_2| = |v_1'| @ |v_2'|$ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
367 |
\end{center}\pause |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
368 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
369 |
\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
|
370 |
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
|
371 |
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
|
372 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
373 |
\end{itemize} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
374 |
\end{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
375 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
376 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
377 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
378 |
\begin{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
379 |
\frametitle{Our Solution} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
380 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
381 |
\begin{itemize} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
382 |
\item A direct definition of what a POSIX value is, using the |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
383 |
relation \smath{s \in r \to v} (our specification)\bigskip |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
384 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
385 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
386 |
\smath{\infer{[] \in \epsilon \to Empty}{}}\hspace{15mm} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
387 |
\smath{\infer{[c] \in c \to Char(c)}{}}\bigskip\medskip |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
388 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
389 |
\smath{\infer{s \in r_1 + r_2 \to Left(v)} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
390 |
{s \in r_1 \to v}}\hspace{10mm} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
391 |
\smath{\infer{s \in r_1 + r_2 \to Right(v)} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
392 |
{s \in r_2 \to v & s \not\in L(r_1)}}\bigskip\medskip |
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 |
\smath{\infer{s_1 @ s_2 \in r_1 \cdot r_2 \to Seq(v_1, v_2)} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
395 |
{\small\begin{array}{l} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
396 |
s_1 \in r_1 \to v_1 \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
397 |
s_2 \in r_2 \to v_2 \\ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
398 |
\neg(\exists s_3\,s_4.\; s_3 \not= [] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
399 |
\wedge s_3 @ s_4 = s_2 \wedge |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
400 |
s_1 @ s_3 \in L(r_1) \wedge |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
401 |
s_4 \in L(r_2)) |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
402 |
\end{array}}} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
403 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
404 |
{\ldots} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
405 |
\end{center} |
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 |
\end{itemize} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
408 |
\end{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
409 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
410 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
411 |
\begin{frame}[c] |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
412 |
\frametitle{Properties} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
413 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
414 |
It is almost trival to prove: |
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 |
\begin{itemize} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
417 |
\item Uniqueness |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
418 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
419 |
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
|
420 |
$v_1 = v_2$ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
421 |
\end{center}\bigskip |
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 |
\item Correctness |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
424 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
425 |
$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
|
426 |
\end{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
427 |
\end{itemize}\bigskip\bigskip\pause |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
428 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
429 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
430 |
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
|
431 |
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
|
432 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
433 |
\begin{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
434 |
$s \in r \to v$ |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
435 |
\end{center} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
436 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
437 |
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
|
438 |
(biggest value for $s$ and $r$) |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
439 |
\end{frame} |
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
440 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
441 |
|
599b2bfcebf6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
442 |
\end{document} |