author | Christian Urban <christian.urban@kcl.ac.uk> |
Fri, 25 Oct 2024 18:54:08 +0100 | |
changeset 971 | 51e00f223792 |
parent 967 | ce5de01b9632 |
child 972 | ebb4a40d9bae |
permissions | -rw-r--r-- |
638 | 1 |
% !TEX program = xelatex |
743 | 2 |
\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer} |
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
3 |
\usepackage{../slides} |
871 | 4 |
\usepackage{../graphicss} |
215
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
5 |
\usepackage{../langs} |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
6 |
\usepackage{../data} |
7 | 7 |
|
764 | 8 |
\usepackage{tcolorbox} |
9 |
\newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black} |
|
10 |
\newtcolorbox{mybox2}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1} |
|
11 |
\newtcolorbox{mybox3}[1]{colback=Cyan!5!white,colframe=Cyan!75!black,fonttitle=\bfseries,title=#1} |
|
12 |
||
13 |
||
14 |
||
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
15 |
\hfuzz=220pt |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
16 |
|
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
17 |
\lstset{language=Scala, |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
18 |
style=mystyle, |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
19 |
numbersep=0pt, |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
20 |
numbers=none, |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
21 |
xleftmargin=0mm} |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
22 |
|
777 | 23 |
\pgfplotsset{compat=1.17} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
24 |
|
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
25 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}} |
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
26 |
|
7 | 27 |
% beamer stuff |
429
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
28 |
\renewcommand{\slidecaption}{CFL 02, King's College London} |
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
29 |
|
7 | 30 |
|
31 |
\begin{document} |
|
32 |
||
33 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
261
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
34 |
\begin{frame}[t] |
7 | 35 |
\frametitle{% |
36 |
\begin{tabular}{@ {}c@ {}} |
|
37 |
\\[-3mm] |
|
429
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
38 |
\LARGE Compilers and \\[-1mm] |
882 | 39 |
\LARGE Formal Languages\\[-5mm] |
7 | 40 |
\end{tabular}} |
41 |
||
261
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
42 |
\normalsize |
7 | 43 |
\begin{center} |
44 |
\begin{tabular}{ll} |
|
882 | 45 |
Email: & christian.urban at kcl.ac.uk\\ |
967 | 46 |
Office Hour: & Friday 12 -- 14\\ |
882 | 47 |
Location: & N7.07 (North Wing, Bush House)\\ |
48 |
Slides \& Progs: & KEATS\\ |
|
49 |
Pollev: & \texttt{\alert{https://pollev.com/cfltutoratki576}}\\ |
|
7 | 50 |
\end{tabular} |
51 |
\end{center} |
|
52 |
||
743 | 53 |
\begin{center} |
54 |
\begin{tikzpicture} |
|
55 |
\node[drop shadow,fill=white,inner sep=0pt] |
|
56 |
{\footnotesize\rowcolors{1}{capri!10}{white} |
|
57 |
\begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline |
|
58 |
1 Introduction, Languages & 6 While-Language \\ |
|
59 |
\cellcolor{blue!50} |
|
60 |
2 Regular Expressions, Derivatives & 7 Compilation, JVM \\ |
|
61 |
3 Automata, Regular Languages & 8 Compiling Functional Languages \\ |
|
62 |
4 Lexing, Tokenising & 9 Optimisations \\ |
|
63 |
5 Grammars, Parsing & 10 LLVM \\ \hline |
|
64 |
\end{tabular}% |
|
65 |
}; |
|
66 |
\end{tikzpicture} |
|
67 |
\end{center} |
|
68 |
||
261
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
69 |
\end{frame} |
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
70 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
7 | 71 |
|
967 | 72 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
73 |
\begin{frame}[c] |
|
74 |
||
75 |
\begin{mybox3}{From Pollev last week}\it |
|
76 |
Will C++ users be publicly shamed and humiliated in front of the class? |
|
77 |
\end{mybox3} |
|
78 |
||
940 | 79 |
\end{frame} |
967 | 80 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
81 |
||
940 | 82 |
|
7 | 83 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
565 | 84 |
\begin{frame}[t] |
630 | 85 |
\frametitle{ |
743 | 86 |
Let's Implement an Efficient\\[-2mm] |
565 | 87 |
Regular Expression Matcher} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
88 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
89 |
\footnotesize |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
90 |
\begin{center} |
967 | 91 |
{\normalsize Graphs: \bl{$a^{?\{n\}} \cdot a^{\{n\}}$} and strings \bl{$\underbrace{\,a\ldots a\,}_{n}$}}\\[-2mm] |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
92 |
\begin{tabular}{@{}cc@{}} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
93 |
\begin{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
94 |
\begin{axis}[ |
967 | 95 |
title={Graph: $\texttt{(a*)*\,b}$ and strings |
96 |
$\underbrace{\texttt{a}\ldots \texttt{a}}_{n}$}, |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
97 |
xlabel={$n$}, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
98 |
x label style={at={(1.05,0.0)}}, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
99 |
ylabel={time in secs}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
100 |
enlargelimits=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
101 |
xtick={0,5,...,30}, |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
102 |
xmax=33, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
103 |
ymax=35, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
104 |
ytick={0,5,...,30}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
105 |
scaled ticks=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
106 |
axis lines=left, |
967 | 107 |
width=5.5cm, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
108 |
height=4.5cm, |
967 | 109 |
legend entries={Python, Java 8, JavaScript, Swift}, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
110 |
legend pos=north west, |
514 | 111 |
legend cell align=left] |
967 | 112 |
\addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data}; |
113 |
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data}; |
|
114 |
\addplot[red,mark=*, mark options={fill=white}] table {re-js.data}; |
|
115 |
\addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data}; |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
116 |
\end{axis} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
117 |
\end{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
118 |
& |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
119 |
\begin{tikzpicture} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
120 |
\begin{axis}[ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
121 |
xlabel={$n$}, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
122 |
x label style={at={(1.1,0.05)}}, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
123 |
ylabel={time in secs}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
124 |
enlargelimits=false, |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
125 |
xtick={0,5000,...,10000}, |
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
126 |
xmax=11500, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
127 |
ymax=35, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
128 |
ytick={0,5,...,30}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
129 |
scaled ticks=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
130 |
axis lines=left, |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
131 |
width=5cm, |
514 | 132 |
height=4.5cm, |
133 |
legend entries={Scala V2,Scala V3}, |
|
565 | 134 |
legend pos=north east, |
514 | 135 |
legend cell align=left] |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
136 |
\addplot[green,mark=square*,mark options={fill=white}] table {re2.data}; |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
137 |
\addplot[black,mark=square*,mark options={fill=white}] table {re3.data}; |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
138 |
\end{axis} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
139 |
\end{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
140 |
\end{tabular} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
141 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
142 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
143 |
\small |
967 | 144 |
\begin{textblock}{14}(1,14.6) |
145 |
In the handouts is a similar graph for \bl{$(a^*)^* \cdot b$} and Java, |
|
146 |
JavaScript, Python and more. |
|
147 |
\end{textblock} |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
148 |
\end{frame} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
149 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
150 |
|
967 | 151 |
{ |
152 |
\setbeamercolor{background canvas}{bg=cream} |
|
153 |
\begin{frame}<1-4>[c] |
|
154 |
\end{frame} |
|
155 |
} |
|
156 |
||
157 |
||
158 |
||
512 | 159 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
638 | 160 |
%\begin{frame}[c] |
161 |
%\frametitle{Evil Regular Expressions} |
|
162 |
% |
|
163 |
%\begin{itemize} |
|
164 |
%\item \alert{R}egular \alert{e}xpression \alert{D}enial \alert{o}f \alert{S}ervice (ReDoS)\bigskip |
|
165 |
%\item Evil regular expressions\medskip |
|
166 |
%\begin{itemize} |
|
167 |
%\item \bl{$a^{?\{n\}} \cdot a^{\{n\}}$} |
|
168 |
%\item \bl{$(a^*)^*$} |
|
169 |
%\item \bl{$([a$\,-\,$z]^+)^*$} |
|
170 |
%\item \bl{$(a + a \cdot a)^*$} |
|
171 |
%\item \bl{$(a + a^?)^*$} |
|
172 |
%\end{itemize} |
|
173 |
% |
|
174 |
%\item sometimes also called \alert{catastrophic backtracking}\bigskip |
|
175 |
%\item \small\ldots I hope you have watched the video by the |
|
176 |
% StackExchange engineer |
|
177 |
%\end{itemize} |
|
178 |
% |
|
179 |
%\end{frame} |
|
512 | 180 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
181 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
182 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
183 |
\begin{frame}[c] |
638 | 184 |
\frametitle{(Basic) Regular Expressions} |
185 |
||
186 |
Their inductive definition: |
|
187 |
||
188 |
\begin{center} |
|
189 |
\begin{tabular}{@ {}rrl@ {\hspace{13mm}}l} |
|
190 |
\bl{$r$} & \bl{$::=$} & \bl{$\ZERO$} & nothing\\ |
|
191 |
& \bl{$\mid$} & \bl{$\ONE$} & empty string / \pcode{""} / $[]$\\ |
|
192 |
& \bl{$\mid$} & \bl{$c$} & character\\ |
|
193 |
& \bl{$\mid$} & \bl{$r_1 + r_2$} & alternative / choice\\ |
|
194 |
& \bl{$\mid$} & \bl{$r_1 \cdot r_2$} & sequence\\ |
|
195 |
& \bl{$\mid$} & \bl{$r^*$} & star (zero or more)\\ |
|
196 |
\end{tabular} |
|
197 |
\end{center} |
|
198 |
\vspace{\fill} |
|
199 |
||
743 | 200 |
%%Q: \;What about \;\bl{$r \cdot 0$} \; ? |
507 | 201 |
\end{frame} |
202 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
203 |
||
638 | 204 |
|
205 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
206 |
\begin{frame}[c] |
|
207 |
\frametitle{ |
|
208 |
When Are Two Regular\\[-1mm] |
|
209 |
Expressions Equivalent?} |
|
210 |
||
211 |
\begin{bubble}[10cm] |
|
212 |
\large |
|
763 | 213 |
Two regular expressions \bl{$r_1$} and \bl{$r_2$} are |
214 |
\alert{\bf{}equivalent} |
|
638 | 215 |
provided:\medskip |
216 |
\begin{center} |
|
217 |
\bl{$r_1 \equiv r_2 \;\;\dn\;\; L(r_1) = L(r_2)$} |
|
218 |
\end{center}\medskip |
|
219 |
\end{bubble} |
|
220 |
||
221 |
\end{frame} |
|
222 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
223 |
||
224 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
225 |
\begin{frame}[c] |
|
226 |
\frametitle{Some Concrete Equivalences} |
|
227 |
||
228 |
\begin{center} |
|
229 |
\bl{\begin{tabular}{rcl} |
|
230 |
$(a + b) + c$ & $\equiv$ & $a + (b + c)$\\ |
|
231 |
$a + a$ & $\equiv$ & $a$\\ |
|
232 |
$a + b$ & $\equiv$ & $b + a$\\ |
|
233 |
$(a \cdot b) \cdot c$ & $\equiv$ & $a \cdot (b \cdot c)$\\ |
|
234 |
$c \cdot (a + b)$ & $\equiv$ & $(c \cdot a) + (c \cdot b)$\bigskip\bigskip\\\pause |
|
235 |
$a \cdot a$ & $\not\equiv$ & $a$\\ |
|
236 |
$a + (b \cdot c)$ & $\not\equiv$ & $(a + b) \cdot (a + c)$\\ |
|
237 |
\end{tabular}} |
|
238 |
\end{center} |
|
239 |
||
240 |
\end{frame} |
|
241 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
242 |
||
243 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
244 |
\begin{frame}[c] |
|
245 |
\frametitle{Some Corner Cases} |
|
246 |
||
247 |
\begin{center} |
|
248 |
\bl{\begin{tabular}{rcl} |
|
249 |
$a \cdot \ZERO$ & $\not\equiv$ & $a$\\ |
|
250 |
$a + \ONE$ & $\not\equiv$ & $a$\\ |
|
251 |
$\ONE$ & $\equiv$ & $\ZERO^*$\\ |
|
252 |
$\ONE^*$ & $\equiv$ & $\ONE$\\ |
|
253 |
$\ZERO^*$ & $\not\equiv$ & $\ZERO$\\ |
|
254 |
\end{tabular}} |
|
255 |
\end{center} |
|
256 |
||
257 |
\end{frame} |
|
258 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
259 |
||
260 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
261 |
\begin{frame}[c] |
|
262 |
\frametitle{Some Simplification Rules} |
|
263 |
||
264 |
\begin{center} |
|
265 |
\bl{\begin{tabular}{rcl} |
|
266 |
$r + \ZERO$ & $\equiv$ & $r$\\ |
|
267 |
$\ZERO + r$ & $\equiv$ & $r$\\ |
|
268 |
$r \cdot \ONE$ & $\equiv$ & $r$\\ |
|
269 |
$\ONE \cdot r$ & $\equiv$ & $r$\\ |
|
270 |
$r \cdot \ZERO$ & $\equiv$ & $\ZERO$\\ |
|
271 |
$\ZERO \cdot r$ & $\equiv$ & $\ZERO$\\ |
|
272 |
$r + r$ & $\equiv$ & $r$ |
|
273 |
\end{tabular}} |
|
274 |
\end{center} |
|
275 |
||
276 |
\end{frame} |
|
277 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
278 |
||
764 | 279 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
280 |
\begin{frame}[c] |
|
281 |
\frametitle{Simplification Example} |
|
282 |
||
283 |
%%Given \bl{$r \dn ((a \cdot b) + b)^*$}, you can simplify as follows |
|
284 |
||
285 |
\begin{center} |
|
286 |
\def\arraystretch{2} |
|
287 |
\begin{tabular}{@{}lcl} |
|
288 |
\bl{$((\ONE \cdot b) + \ZERO) \cdot r$} |
|
289 |
& \bl{$\Rightarrow$} & \bl{$((\underline{\ONE \cdot b}) + \ZERO) \cdot r$}\\ |
|
290 |
& \bl{$=$} & \bl{$(\underline{b + \ZERO}) \cdot r$}\\ |
|
291 |
& \bl{$=$} & \bl{$b \cdot r$}\\ |
|
292 |
\end{tabular} |
|
293 |
\end{center} |
|
294 |
||
295 |
\end{frame} |
|
296 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
297 |
||
298 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
299 |
\begin{frame}[c] |
|
300 |
\frametitle{Simplification Example} |
|
301 |
||
302 |
%%Given \bl{$r \dn ((a \cdot b) + b)^*$}, you can simplify as follows |
|
303 |
||
304 |
\begin{center} |
|
305 |
\def\arraystretch{2} |
|
306 |
\begin{tabular}{@{}lcl} |
|
307 |
\bl{$((\ZERO \cdot b) + \ZERO) \cdot r$} |
|
308 |
& \bl{$\Rightarrow$} & \bl{$((\underline{\ZERO \cdot b}) + \ZERO) \cdot r$}\\ |
|
309 |
& \bl{$=$} & \bl{$(\underline{\ZERO + \ZERO}) \cdot r$}\\ |
|
310 |
& \bl{$=$} & \bl{$\ZERO \cdot r$}\\ |
|
311 |
& \bl{$=$} & \bl{$\ZERO$}\\ |
|
312 |
\end{tabular} |
|
313 |
\end{center} |
|
314 |
||
315 |
\end{frame} |
|
316 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
566 | 317 |
|
507 | 318 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
565 | 319 |
\begin{frame}[t] |
320 |
\frametitle{Semantic Derivative\\[5mm]} |
|
321 |
||
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
322 |
\begin{itemize} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
323 |
\item The \alert{\bf Semantic Derivative} of a |
565 | 324 |
\underline{language}\\ w.r.t.~to a character \bl{$c$}: |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
325 |
\bigskip |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
326 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
327 |
\begin{center} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
328 |
\bl{$\Der\,c\,A \dn \{ s \;|\; c\!::\!s \in A\}$ } |
565 | 329 |
\end{center}\bigskip |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
330 |
|
630 | 331 |
For \bl{$A = \{\mathit{foo}, \mathit{bar}, \mathit{frak}\}$} then |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
332 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
333 |
\begin{center} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
334 |
\bl{\begin{tabular}{l@{\hspace{2mm}}c@{\hspace{2mm}}l} |
630 | 335 |
$\Der\,f\,A$ & $=$ & $\{\mathit{oo}, \mathit{rak}\}$\\ |
336 |
$\Der\,b\,A$ & $=$ & $\{\mathit{ar}\}$\\ |
|
565 | 337 |
$\Der\,a\,A$ & $=$ & $\{\}$\pause |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
338 |
\end{tabular}} |
638 | 339 |
\end{center}\medskip |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
340 |
|
630 | 341 |
|
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
342 |
We can extend this definition to strings |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
343 |
\[ |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
344 |
\bl{\Ders\,s\,A = \{s'\;|\;s\,@\,s' \in A\}} |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
345 |
\] |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
346 |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
347 |
\end{itemize} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
348 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
349 |
\end{frame} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
350 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
351 |
|
763 | 352 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
353 |
\begin{frame}[c] |
|
354 |
\frametitle{The Specification for Matching} |
|
355 |
||
356 |
\begin{bubble}[10cm] |
|
357 |
\large |
|
358 |
A regular expression \bl{$r$} matches a string~\bl{$s$} |
|
359 |
provided: |
|
360 |
\begin{center} |
|
361 |
\bl{$s \in L(r)$} |
|
362 |
\end{center}\medskip |
|
363 |
\end{bubble} |
|
364 |
||
365 |
\bigskip\bigskip |
|
366 |
||
367 |
\ldots and the point of the this lecture is to decide this problem as |
|
368 |
fast as possible (unlike Python, Ruby, Java etc) |
|
369 |
||
370 |
\end{frame} |
|
371 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
771 | 372 |
|
373 |
||
512 | 374 |
|
375 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
376 |
\begin{frame}[c] |
|
573 | 377 |
\frametitle{\mbox{Brzozowski's Algorithm (1)}} |
11 | 378 |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
379 |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
380 |
\ldots{}whether a regular expression can match the empty string: |
11 | 381 |
\begin{center} |
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
382 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
429
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
383 |
\bl{$nullable(\ZERO)$} & \bl{$\dn$} & \bl{\textit{false}}\\ |
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
384 |
\bl{$nullable(\ONE)$} & \bl{$\dn$} & \bl{\textit{true}}\\ |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
385 |
\bl{$nullable (c)$} & \bl{$\dn$} & \bl{\textit{false}}\\ |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
386 |
\bl{$nullable (r_1 + r_2)$} & \bl{$\dn$} & \bl{$nullable(r_1) \vee nullable(r_2)$} \\ |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
387 |
\bl{$nullable (r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$nullable(r_1) \wedge nullable(r_2)$} \\ |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
388 |
\bl{$nullable (r^*)$} & \bl{$\dn$} & \bl{\textit{true}}\\ |
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
389 |
\end{tabular} |
16 | 390 |
\end{center} |
391 |
||
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
392 |
\end{frame} |
11 | 393 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
394 |
||
395 |
||
396 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
397 |
\begin{frame}[c] |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
398 |
\frametitle{The Derivative of a Rexp} |
7 | 399 |
|
400 |
\large |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
401 |
If \bl{$r$} matches the string \bl{$c\!::\!s$}, what is a regular |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
402 |
expression that matches just \bl{$s$}?\bigskip\bigskip\bigskip\bigskip |
7 | 403 |
|
404 |
\small |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
405 |
\bl{$\der\,c\,r$} gives the answer, Brzozowski 1964 |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
406 |
\end{frame} |
7 | 407 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
408 |
||
409 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
410 |
\begin{frame}[c] |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
411 |
\frametitle{The Derivative of a Rexp} |
7 | 412 |
|
413 |
\begin{center} |
|
414 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {\hspace{-10mm}}l@ {}} |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
415 |
\bl{$\der\, c\, (\ZERO)$} & \bl{$\dn$} & \bl{$\ZERO$} & \\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
416 |
\bl{$\der\, c\, (\ONE)$} & \bl{$\dn$} & \bl{$\ZERO$} & \\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
417 |
\bl{$\der\, c\, (d)$} & \bl{$\dn$} & \bl{if $c = d$ then $\ONE$ else $\ZERO$} & \\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
418 |
\bl{$\der\, c\, (r_1 + r_2)$} & \bl{$\dn$} & \bl{$\der\, c\, r_1 + \der\, c\, r_2$} & \\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
419 |
\bl{$\der\, c\, (r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{if $nullable (r_1)$}\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
420 |
& & \bl{then $(\der\,c\,r_1) \cdot r_2 + \der\, c\, r_2$}\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
421 |
& & \bl{else $(\der\, c\, r_1) \cdot r_2$}\\ |
638 | 422 |
\bl{$\der\, c\, (r^*)$} & \bl{$\dn$} & \bl{$(\der\,c\,r) \cdot (r^*)$} &\medskip\bigskip\\\pause |
7 | 423 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
424 |
\bl{$\ders\, []\, r$} & \bl{$\dn$} & \bl{$r$} & \\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
425 |
\bl{$\ders\, (c\!::\!s)\, r$} & \bl{$\dn$} & \bl{$\ders\,s\,(\der\,c\,r)$} & \\ |
7 | 426 |
\end{tabular} |
427 |
\end{center} |
|
428 |
||
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
429 |
\end{frame} |
7 | 430 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
431 |
||
941 | 432 |
{ |
433 |
\setbeamercolor{background canvas}{bg=cream} |
|
434 |
\begin{frame}<1-6>[c] |
|
435 |
\end{frame} |
|
436 |
} |
|
437 |
||
438 |
||
7 | 439 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
440 |
\begin{frame}[c] |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
441 |
\frametitle{Examples} |
7 | 442 |
|
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
443 |
Given \bl{$r \dn ((a \cdot b) + b)^*$} what is |
7 | 444 |
|
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
445 |
\begin{center} |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
446 |
\begin{tabular}{l} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
447 |
\bl{$\der\,a\,r =\;?$}\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
448 |
\bl{$\der\,b\,r =\;?$}\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
449 |
\bl{$\der\,c\,r =\;?$} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
450 |
\end{tabular} |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
451 |
\end{center} |
7 | 452 |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
453 |
\end{frame} |
7 | 454 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
455 |
||
17 | 456 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
431 | 457 |
\begin{frame}[c] |
764 | 458 |
\frametitle{Derivative Example} |
459 |
||
460 |
Given \bl{$r \dn ((a \cdot b) + b)^*$} what is |
|
431 | 461 |
|
462 |
\begin{center} |
|
764 | 463 |
\def\arraystretch{1.5} |
464 |
\begin{tabular}{@{}lcl} |
|
465 |
\bl{$\der\,a\,((a \cdot b) + b)^*$} |
|
466 |
& \bl{$\Rightarrow$}& \bl{$\der\,a\, \underline{((a \cdot b) + b)^*}$}\\ |
|
467 |
& \bl{$=$} & \bl{$(der\,a\,(\underline{(a \cdot b) + b})) \cdot r$}\\ |
|
468 |
& \bl{$=$} & \bl{$((der\,a\,(\underline{a \cdot b})) + (der\,a\,b)) \cdot r$}\\ |
|
469 |
& \bl{$=$} & \bl{$(((der\,a\,\underline{a}) \cdot b) + (der\,a\,b)) \cdot r$}\\ |
|
470 |
& \bl{$=$} & \bl{$((\ONE \cdot b) + (der\,a\,\underline{b})) \cdot r$}\\ |
|
471 |
& \bl{$=$} & \bl{$((\ONE \cdot b) + \ZERO) \cdot r$} |
|
431 | 472 |
\end{tabular} |
473 |
\end{center} |
|
474 |
||
764 | 475 |
\end{frame} |
476 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
477 |
||
478 |
||
479 |
||
480 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
481 |
\begin{frame}[c] |
|
482 |
\frametitle{\mbox{The Brzozowski Algorithm}} |
|
483 |
||
484 |
%\begin{center} |
|
485 |
%\begin{tabular}{l} |
|
486 |
%\bl{$\textit{matcher}\,r\,s \dn \textit{nullable}(\ders\;s\;r)$} |
|
487 |
%\end{tabular} |
|
488 |
%\end{center} |
|
489 |
||
490 |
\begin{center} |
|
491 |
\begin{mybox3}{} |
|
765 | 492 |
\centering |
764 | 493 |
\bl{$\textit{matcher}\,r\,s \dn \textit{nullable}(\ders\;s\;r)$} |
494 |
\end{mybox3} |
|
495 |
\end{center} |
|
431 | 496 |
|
497 |
\end{frame} |
|
498 |
%%%%%%%%%%%%%%%%% |
|
499 |
||
500 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
17 | 501 |
\begin{frame}[t] |
565 | 502 |
\frametitle{Brzozowski: An Example} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
503 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
504 |
Does \bl{$r_1$} match \bl{$abc$}? |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
505 |
\begin{center} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
506 |
\begin{tabular}{@{}rl@{}l@{}} |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
507 |
Step 1: & build derivative of \bl{$a$} and \bl{$r_1$} & \bl{$(r_2 = \der\,a\,r_1)$}\smallskip\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
508 |
Step 2: & build derivative of \bl{$b$} and \bl{$r_2$} & \bl{$(r_3 = \der\,b\,r_2)$}\smallskip\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
509 |
Step 3: & build derivative of \bl{$c$} and \bl{$r_3$} & \bl{$(r_4 = \der\,c\,r_3)$}\smallskip\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
510 |
Step 4: & the string is exhausted: & \bl{($nullable(r_4))$}\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
511 |
& test whether \bl{$r_4$} can recognise\\ |
565 | 512 |
& the empty string\medskip\\ |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
513 |
Output: & result of the test\\ |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
514 |
& $\Rightarrow \bl{\textit{true}} \,\text{or}\, |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
515 |
\bl{\textit{false}}$\\ |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
516 |
\end{tabular} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
517 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
518 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
519 |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
520 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
521 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
522 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
523 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
524 |
\begin{frame}[c] |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
525 |
\frametitle{The Idea of the Algorithm} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
526 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
527 |
If we want to recognise the string \bl{$abc$} with regular |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
528 |
expression \bl{$r_1$} then\medskip |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
529 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
530 |
\begin{enumerate} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
531 |
\item \bl{$\Der\,a\,(L(r_1))$}\pause |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
532 |
\item \bl{$\Der\,b\,(\Der\,a\,(L(r_1)))$}\pause |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
533 |
\item \bl{$\Der\,c\,(\Der\,b\,(\Der\,a\,(L(r_1))))$}\bigskip |
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
534 |
\item finally we test whether the empty string is in this |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
535 |
set; same for \bl{$\Ders\,abc\,(L(r_1))$}.\medskip |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
536 |
\end{enumerate} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
537 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
538 |
The matching algorithm works similarly, just over regular expressions instead of sets. |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
539 |
\end{frame} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
540 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
541 |
|
764 | 542 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
543 |
\begin{frame}[c] |
|
544 |
\frametitle{The Idea with Derivatives} |
|
545 |
||
546 |
Input: string \bl{$abc$} and regular expression \bl{$r$}\medskip |
|
547 |
||
548 |
\begin{enumerate} |
|
549 |
\item \bl{$der\,a\,r$} |
|
550 |
\item \bl{$der\,b\,(der\,a\,r)$} |
|
551 |
\item \bl{$der\,c\,(der\,b\,(der\,a\,r))$}\bigskip\pause |
|
552 |
\item finally check whether the last regular expression can match the empty string |
|
553 |
\end{enumerate} |
|
554 |
||
555 |
\end{frame} |
|
556 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
557 |
||
765 | 558 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
559 |
\begin{frame}[c] |
|
560 |
\frametitle{\boldmath\;$a^{?\{n\}} \cdot a^{\{n\}}$} |
|
561 |
||
562 |
\begin{center} |
|
563 |
\begin{tikzpicture} |
|
564 |
\begin{axis}[ |
|
565 |
xlabel={$n$}, |
|
566 |
x label style={at={(1.05,0.0)}}, |
|
567 |
ylabel={time in secs}, |
|
568 |
enlargelimits=false, |
|
569 |
xtick={0,5,...,30}, |
|
570 |
xmax=31, |
|
571 |
ytick={0,5,...,30}, |
|
572 |
scaled ticks=false, |
|
573 |
axis lines=left, |
|
574 |
width=7cm, |
|
575 |
height=7cm, |
|
576 |
legend entries={Python,Ruby}, |
|
577 |
legend pos=outer north east, |
|
578 |
legend cell align=left |
|
579 |
] |
|
580 |
\addplot[blue,mark=*, mark options={fill=white}] |
|
581 |
table {re-python.data}; |
|
582 |
\addplot[brown,mark=pentagon*, mark options={fill=white}] |
|
583 |
table {re-ruby.data}; |
|
584 |
\end{axis} |
|
585 |
\end{tikzpicture} |
|
586 |
\end{center} |
|
587 |
||
588 |
\end{frame} |
|
589 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
590 |
||
591 |
||
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
592 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
593 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
594 |
\begin{frame}[c] |
638 | 595 |
\frametitle{Oops\ldots \boldmath\;$a^{?\{n\}} \cdot a^{\{n\}}$} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
596 |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
597 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
598 |
\begin{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
599 |
\begin{axis}[ |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
600 |
xlabel={$n$}, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
601 |
x label style={at={(1.05,0.0)}}, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
602 |
ylabel={time in secs}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
603 |
enlargelimits=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
604 |
xtick={0,5,...,30}, |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
605 |
xmax=31, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
606 |
ytick={0,5,...,30}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
607 |
scaled ticks=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
608 |
axis lines=left, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
609 |
width=7cm, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
610 |
height=7cm, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
611 |
legend entries={Python,Ruby,Scala V1}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
612 |
legend pos=outer north east, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
613 |
legend cell align=left |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
614 |
] |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
615 |
\addplot[blue,mark=*, mark options={fill=white}] |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
616 |
table {re-python.data}; |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
617 |
\addplot[brown,mark=pentagon*, mark options={fill=white}] |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
618 |
table {re-ruby.data}; |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
619 |
\addplot[red,mark=triangle*,mark options={fill=white}] |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
620 |
table {re1.data}; |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
621 |
\end{axis} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
622 |
\end{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
623 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
624 |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
625 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
626 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
627 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
628 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
565 | 629 |
\begin{frame}[t] |
630 |
\frametitle{A Problem\medskip} |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
631 |
|
345
0922b3e01289
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
342
diff
changeset
|
632 |
We represented the ``n-times'' \bl{$a^{\{n\}}$} as a |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
633 |
sequence regular expression: |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
634 |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
635 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
636 |
\begin{tabular}{rl} |
767 | 637 |
0: & \bl{$\ONE$}\\ |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
638 |
1: & \bl{$a$}\\ |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
639 |
2: & \bl{$a\cdot a$}\\ |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
640 |
3: & \bl{$a\cdot a\cdot a$}\\ |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
641 |
& \ldots\\ |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
642 |
13: & \bl{$a\cdot a\cdot a\cdot a\cdot a\cdot a\cdot a\cdot a\cdot a\cdot a\cdot a\cdot a\cdot a$}\\ |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
643 |
& \ldots\\ |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
644 |
20: |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
645 |
\end{tabular} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
646 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
647 |
|
345
0922b3e01289
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
342
diff
changeset
|
648 |
This problem is aggravated with \bl{$a^?$} being represented |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
649 |
as \bl{$a + \ONE$}. |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
650 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
651 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
652 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
653 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
654 |
\begin{frame}[c] |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
655 |
\frametitle{Solving the Problem} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
656 |
|
514 | 657 |
What happens if we extend our regular expressions with explicit |
658 |
constructors |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
659 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
660 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
661 |
\begin{tabular}{rcl} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
662 |
\bl{$r$} & \bl{$::=$} & \bl{\ldots}\\ |
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
663 |
& \bl{$\mid$} & \bl{$r^{\{n\}}$}\\ |
345
0922b3e01289
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
342
diff
changeset
|
664 |
& \bl{$\mid$} & \bl{$r^?$} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
665 |
\end{tabular} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
666 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
667 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
668 |
What is their meaning?\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
669 |
What are the cases for \bl{$nullable$} and \bl{$\der$}? |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
670 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
671 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
672 |
|
769 | 673 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
674 |
\begin{frame}[c] |
|
675 |
\frametitle{$der$ for $n$-times} |
|
676 |
||
677 |
Case \bl{$n = 2$} and \bl{$r \cdot r$}: |
|
678 |
||
679 |
\begin{center} |
|
680 |
\begin{tabular}{lcl} |
|
681 |
\bl{$der\,c\,(r\cdot r)$} & \bl{$\dn$} & \bl{if \; $nullable(r)$}\\ |
|
682 |
& & \bl{then \; \alert<3>{$(der\,c\,r)\cdot r + der\,c\,r$}}\\ |
|
683 |
& & \bl{else \; $(der\,c\,r)\cdot r$}\bigskip\pause\\ |
|
684 |
my claim & & \bl{$\equiv\;$} \bl{$(der\,c\,r)\cdot r$}\\ |
|
685 |
(in this case) |
|
686 |
\end{tabular} |
|
687 |
\end{center} |
|
688 |
||
689 |
\end{frame} |
|
690 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
691 |
||
692 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
693 |
\begin{frame}[t] |
|
694 |
||
695 |
We know \bl{$nullable(r)$} holds!\pause |
|
696 |
||
697 |
\begin{center} |
|
698 |
\begin{tabular}{@{}lcl} |
|
699 |
\bl{$(der\,c\,r)\cdot r + der\,c\,r$}\pause |
|
700 |
& \bl{$\equiv$} & \bl{$(der\,c\,r)\cdot r + (der\,c\,r) \cdot \ONE$}\medskip\pause\\ |
|
701 |
& \bl{$\equiv$} & \bl{$(der\,c\,r)\cdot (r + \ONE)$}\medskip\pause\\ |
|
702 |
& \bl{$\equiv$} & \bl{$(der\,c\,r)\cdot r$}\\ |
|
703 |
\multicolumn{3}{r}{\small(remember \bl{$r$} is nullable)} |
|
704 |
\end{tabular} |
|
705 |
\end{center}\pause |
|
706 |
||
707 |
\rule{13cm}{0.8mm} |
|
708 |
||
709 |
\begin{textblock}{13}(2,10) |
|
710 |
\only<6>{% |
|
711 |
\begin{tabular}{lcl} |
|
712 |
\bl{$der\,c\,(r\cdot r)$} & \bl{$\dn$} & \bl{if \; $nullable(r)$}\\ |
|
713 |
& & \bl{then \; $(der\,c\,r)\cdot r + der\,c\,r$}\\ |
|
714 |
& & \bl{else \; $(der\,c\,r)\cdot r$} |
|
715 |
\end{tabular}} |
|
716 |
\only<7>{% |
|
717 |
\begin{tabular}{lcl} |
|
718 |
\bl{$der\,c\,(r\cdot r)$} & \bl{$\dn$} & \bl{if \; $nullable(r)$}\\ |
|
719 |
& & \bl{then \; $(der\,c\,r)\cdot r$}\\ |
|
720 |
& & \bl{else \; $(der\,c\,r)\cdot r$} |
|
721 |
\end{tabular}} |
|
722 |
\only<8>{% |
|
723 |
\begin{tabular}{lcl} |
|
724 |
\bl{$der\,c\,(r\cdot r)$} & \bl{$\dn$} & \bl{$(der\,c\,r)\cdot r$} |
|
725 |
\end{tabular}} |
|
726 |
\end{textblock} |
|
727 |
||
728 |
||
729 |
\end{frame} |
|
730 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
731 |
||
732 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
733 |
\begin{frame}[c] |
|
734 |
||
735 |
\begin{center} |
|
736 |
\begin{tabular}{ll@{\hspace{10mm}}l} |
|
737 |
& \bl{$r\{n\}$} & \bl{$der$}\hspace{20mm}\mbox{}\\\hline\\[-4mm] |
|
738 |
\bl{$n = 0$} : & \bl{$\ONE$} & \bl{$\ZERO$}\\ |
|
739 |
\bl{$n = 1$} : & \bl{$r$} & \bl{$(der\,c\,r)$}\\ |
|
740 |
\bl{$n = 2$} : & \bl{$r\cdot r$} & \bl{$(der\,c\,r)\cdot r$}\\ |
|
741 |
\bl{$n = 3$} : & \bl{$r\cdot r\cdot r$}& \only<1>{???}\only<2->{\bl{$(der\,c\,r)\cdot r\cdot r$}}\\ |
|
742 |
\quad\vdots |
|
743 |
\end{tabular} |
|
744 |
\end{center} |
|
745 |
||
746 |
\begin{textblock}{13}(1,11) |
|
747 |
\only<3->{% |
|
748 |
\begin{tabular}{rcl} |
|
749 |
\bl{$nullable(r\{n\})$} & \bl{$\dn$} & |
|
750 |
\bl{if\; $n = 0$\; then\; $true$\; else\; $nullable(r)$}\\ |
|
751 |
\bl{$der\,c\,(r\{n\})$} & \bl{$\dn$} & |
|
752 |
\bl{if\; $n = 0$\; then\; $\ZERO$\; else\; $(der\,c\,r)\cdot r\{n - 1\}$} |
|
753 |
\end{tabular}} |
|
754 |
\end{textblock} |
|
755 |
||
756 |
\end{frame} |
|
757 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
758 |
||
759 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
760 |
\begin{frame}[c] |
|
761 |
||
762 |
\begin{textblock}{13}(1.5,4) |
|
763 |
\only<1-6>{% |
|
764 |
\begin{tabular}{@{}lcl@{}} |
|
765 |
\bl{$der\,c\,(r\cdot r\cdot r)$} |
|
766 |
& \bl{$\dn$} & \bl{if $nullable(r)$}\medskip\\ |
|
767 |
& & \only<1>{\bl{then\; $(der\,c\,r)\cdot r\cdot r + der\,c\,(r\cdot r)$}}% |
|
768 |
\only<2>{\bl{then\; $(der\,c\,r)\cdot r\cdot r + (der\,c\,r)\cdot r$}}% |
|
769 |
\only<3>{\bl{then\; $(der\,c\,r)\cdot (r\cdot r + r)$}}% |
|
770 |
\only<4>{\bl{then\; $(der\,c\,r)\cdot (r\cdot (r + \ONE))$}}% |
|
771 |
\only<5>{\bl{then\; $(der\,c\,r)\cdot (r\cdot r)$}}% |
|
772 |
\only<6>{\bl{then\; $(der\,c\,r)\cdot r\cdot r$}}\medskip\\ |
|
773 |
& & \bl{else\; $(der\,c\,r)\cdot r\cdot r$}\\ |
|
774 |
\end{tabular}} |
|
775 |
\only<7->{% |
|
776 |
\begin{tabular}{@{}lcl@{}} |
|
777 |
\bl{$der\,c\,(r\cdot r\cdot r)$} |
|
778 |
& \bl{$\dn$} & \bl{$(der\,c\,r)\cdot r\cdot r$}% |
|
779 |
\end{tabular}} |
|
780 |
\end{textblock} |
|
781 |
||
782 |
\end{frame} |
|
783 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
784 |
||
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
785 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
786 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
787 |
\begin{frame}[t] |
638 | 788 |
\frametitle{Brzozowski: \boldmath$a^{?\{n\}} \cdot a^{\{n\}}$} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
789 |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
790 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
791 |
\begin{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
792 |
\begin{axis}[ |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
793 |
xlabel={$n$}, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
794 |
x label style={at={(1.05,0.0)}}, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
795 |
ylabel={time in secs}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
796 |
enlargelimits=false, |
434
8664ff87cd77
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
433
diff
changeset
|
797 |
xtick={0,200,...,1100}, |
8664ff87cd77
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
433
diff
changeset
|
798 |
xmax=1200, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
799 |
ytick={0,5,...,30}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
800 |
scaled ticks=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
801 |
axis lines=left, |
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
802 |
width=8cm, |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
803 |
height=6.5cm, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
804 |
legend entries={Python,Ruby,Scala V1,Scala V2}, |
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
805 |
legend pos=outer north east, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
806 |
legend cell align=left |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
807 |
] |
434
8664ff87cd77
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
433
diff
changeset
|
808 |
\addplot[blue,mark=*, mark options={fill=white}] table {re-python.data}; |
8664ff87cd77
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
433
diff
changeset
|
809 |
\addplot[brown,mark=pentagon*, mark options={fill=white}] table {re-ruby.data}; |
8664ff87cd77
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
433
diff
changeset
|
810 |
\addplot[red,mark=triangle*,mark options={fill=white}] table {re1.data}; |
8664ff87cd77
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
433
diff
changeset
|
811 |
\addplot[green,mark=square*,mark options={fill=white}] table {re2.data}; |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
812 |
\end{axis} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
813 |
\end{tikzpicture} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
814 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
815 |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
816 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
817 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
818 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
819 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
820 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
821 |
\begin{frame}[c] |
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
822 |
\frametitle{Examples} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
823 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
824 |
Recall the example of \bl{$r \dn ((a \cdot b) + b)^*$} with |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
825 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
826 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
827 |
\begin{tabular}{l} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
828 |
\bl{$\der\,a\,r = ((\ONE \cdot b) + \ZERO) \cdot r$}\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
829 |
\bl{$\der\,b\,r = ((\ZERO \cdot b) + \ONE)\cdot r$}\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
830 |
\bl{$\der\,c\,r = ((\ZERO \cdot b) + \ZERO)\cdot r$} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
831 |
\end{tabular} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
832 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
833 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
834 |
What are these regular expressions equivalent to? |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
835 |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
836 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
837 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
838 |
|
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
839 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
840 |
\begin{frame}[c] |
565 | 841 |
\frametitle{Simplification Rules} |
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
842 |
|
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
843 |
\begin{center} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
844 |
\bl{\begin{tabular}{rcl} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
845 |
$r + \ZERO$ & $\Rightarrow$ & $r$\\ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
846 |
$\ZERO + r$ & $\Rightarrow$ & $r$\\ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
847 |
$r \cdot \ONE$ & $\Rightarrow$ & $r$\\ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
848 |
$\ONE \cdot r$ & $\Rightarrow$ & $r$\\ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
849 |
$r \cdot \ZERO$ & $\Rightarrow$ & $\ZERO$\\ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
850 |
$\ZERO \cdot r$ & $\Rightarrow$ & $\ZERO$\\ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
851 |
$r + r$ & $\Rightarrow$ & $r$ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
852 |
\end{tabular}} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
853 |
\end{center} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
854 |
|
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
855 |
\footnotesize |
565 | 856 |
\lstinputlisting[firstline=22,lastline=26]{../progs/app6.scala} |
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
857 |
\end{frame} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
858 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
859 |
|
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
860 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
861 |
\begin{frame}[c] |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
862 |
|
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
863 |
\footnotesize |
565 | 864 |
\lstinputlisting[firstline=1,lastline=21]{../progs/app6.scala} |
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
865 |
|
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
866 |
\end{frame} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
867 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
868 |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
869 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
870 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
871 |
\begin{frame}[t] |
638 | 872 |
\frametitle{Brzozowski: \boldmath$a^{?\{n\}} \cdot a^{\{n\}}$} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
873 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
874 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
875 |
\begin{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
876 |
\begin{axis}[ |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
877 |
xlabel={$n$}, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
878 |
x label style={at={(1.05,0.0)}}, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
879 |
ylabel={time in secs}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
880 |
enlargelimits=false, |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
881 |
xtick={0,5000,...,10000}, |
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
882 |
xmax=11000, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
883 |
ymax=35, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
884 |
ytick={0,5,...,30}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
885 |
scaled ticks=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
886 |
axis lines=left, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
887 |
width=9cm, |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
888 |
height=7cm, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
889 |
legend entries={Scala V2,Scala V3}, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
890 |
legend pos=north east |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
891 |
] |
434
8664ff87cd77
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
433
diff
changeset
|
892 |
\addplot[green,mark=square*,mark options={fill=white}] table {re2.data}; |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
893 |
\addplot[black,mark=square*,mark options={fill=white}] table {re3.data}; |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
894 |
\end{axis} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
895 |
\end{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
896 |
\end{center} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
897 |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
898 |
\end{frame} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
899 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
900 |
|
778 | 901 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
902 |
\begin{frame}[t] |
|
903 |
\frametitle{Brzozowski: \boldmath$a^{?\{n\}} \cdot a^{\{n\}}$} |
|
904 |
||
905 |
\begin{center} |
|
906 |
\begin{tikzpicture} |
|
907 |
\begin{axis}[ |
|
908 |
xlabel={$n$}, |
|
909 |
x label style={at={(1.05,0.0)}}, |
|
910 |
ylabel={time in secs}, |
|
911 |
enlargelimits=false, |
|
912 |
xtick={0,5000,...,10000}, |
|
913 |
xmax=11000, |
|
914 |
ymax=35, |
|
915 |
ytick={0,5,...,30}, |
|
916 |
scaled ticks=false, |
|
917 |
axis lines=left, |
|
918 |
width=9cm, |
|
919 |
height=7cm, |
|
920 |
legend entries={Scala V2,Scala V3,Rust}, |
|
921 |
legend pos=north east |
|
922 |
] |
|
923 |
\addplot[green,mark=square*,mark options={fill=white}] table {re2.data}; |
|
924 |
\addplot[black,mark=square*,mark options={fill=white}] table {re3.data}; |
|
925 |
\addplot[pink,mark=triangle,mark options={fill=pink}] table {re-rust.data}; |
|
926 |
\end{axis} |
|
927 |
\end{tikzpicture} |
|
928 |
\end{center} |
|
929 |
||
782 | 930 |
code by Archie Collard |
931 |
||
778 | 932 |
\end{frame} |
933 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
934 |
||
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
935 |
|
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
936 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
937 |
\begin{frame}[c] |
743 | 938 |
\frametitle{Another Example \boldmath$(a^*)^* \cdot b$} |
565 | 939 |
|
638 | 940 |
\bigskip |
565 | 941 |
\begin{center} |
942 |
\begin{tikzpicture} |
|
943 |
\begin{axis}[ |
|
944 |
xlabel={$n$}, |
|
945 |
x label style={at={(1.05,0.0)}}, |
|
946 |
ylabel={time in secs}, |
|
947 |
enlargelimits=false, |
|
948 |
xtick={0,5,...,30}, |
|
949 |
xmax=33, |
|
950 |
ymax=35, |
|
951 |
ytick={0,10,...,30}, |
|
952 |
scaled ticks=false, |
|
953 |
axis lines=left, |
|
954 |
width=9cm, |
|
638 | 955 |
height=5.5cm, |
777 | 956 |
legend entries={Java 8,Python,JavaScript,Swift,Dart}, |
778 | 957 |
legend pos=outer north east, |
565 | 958 |
legend cell align=left] |
959 |
\addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data}; |
|
960 |
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data}; |
|
638 | 961 |
\addplot[red,mark=*, mark options={fill=white}] table {re-js.data}; |
767 | 962 |
\addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data}; |
777 | 963 |
\addplot[brown,mark=*, mark options={fill=white}] table {re-dart.data}; |
565 | 964 |
\end{axis} |
965 |
\end{tikzpicture} |
|
966 |
\end{center} |
|
967 |
||
968 |
Regex: \bl{$(a^*)^* \cdot b$} |
|
969 |
||
970 |
Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$} |
|
971 |
||
972 |
\end{frame} |
|
973 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
974 |
||
975 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
976 |
\begin{frame}[c] |
|
638 | 977 |
\frametitle{Same Example in Java 9+} |
565 | 978 |
|
979 |
\begin{center} |
|
980 |
\begin{tikzpicture} |
|
981 |
\begin{axis}[ |
|
982 |
xlabel={$n$}, |
|
983 |
x label style={at={(1.09,-0.15)}}, |
|
984 |
ylabel={time in secs}, |
|
985 |
scaled x ticks=false, |
|
986 |
enlargelimits=false, |
|
987 |
xtick distance=10000, |
|
988 |
xmax=44000, |
|
989 |
ytick={0,10,...,30}, |
|
990 |
ymax=35, |
|
991 |
axis lines=left, |
|
992 |
width=9cm, |
|
993 |
height=5cm, |
|
994 |
legend entries={Java \liningnums{9}+}, |
|
995 |
legend pos=north west, |
|
996 |
legend cell align=left] |
|
997 |
\addplot[blue,mark=square*,mark options={fill=white}] table {re-java9.data}; |
|
998 |
\end{axis} |
|
999 |
\end{tikzpicture} |
|
1000 |
\end{center} |
|
1001 |
||
1002 |
Regex: \bl{$(a^*)^* \cdot b$} |
|
1003 |
||
1004 |
Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$} |
|
1005 |
||
1006 |
\end{frame} |
|
1007 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1008 |
||
1009 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1010 |
\begin{frame}[c] |
|
646 | 1011 |
\frametitle{\ldots{}and with Brzozowski} |
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1012 |
|
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1013 |
\begin{center} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1014 |
\begin{tikzpicture} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1015 |
\begin{axis}[ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1016 |
xlabel={$n$}, |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1017 |
x label style={at={(1.09,0.0)}}, |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1018 |
ylabel={time in secs}, |
565 | 1019 |
scaled x ticks=false, |
1020 |
xtick distance=2000000, |
|
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1021 |
enlargelimits=false, |
565 | 1022 |
xmax=6400000, |
514 | 1023 |
ytick={0,10,...,30}, |
1024 |
ymax=35, |
|
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1025 |
axis lines=left, |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1026 |
width=9cm, |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1027 |
height=5cm, |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1028 |
legend entries={Scala V3}, |
565 | 1029 |
legend pos=north west, |
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1030 |
legend cell align=left] |
514 | 1031 |
%\addplot[green,mark=square*,mark options={fill=white}] table {re2a.data}; |
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1032 |
\addplot[black,mark=square*,mark options={fill=white}] table {re3a.data}; |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1033 |
\end{axis} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1034 |
\end{tikzpicture} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1035 |
\end{center} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1036 |
|
565 | 1037 |
Regex: \bl{$(a^*)^* \cdot b$} |
1038 |
||
1039 |
Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$} |
|
1040 |
||
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1041 |
\end{frame} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1042 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
1043 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1044 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
573 | 1045 |
\begin{frame}[c] |
1046 |
\frametitle{\mbox{What is good about this Alg.}} |
|
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1047 |
|
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1048 |
\begin{itemize} |
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1049 |
\item extends to most regular expressions, for example |
573 | 1050 |
\bl{$\sim r$} (next slide) |
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1051 |
|
769 | 1052 |
\item is easy to implement in a functional language |
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1053 |
|
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1054 |
\item the algorithm is already quite old; there is still |
514 | 1055 |
work to be done to use it as a tokenizer (that is relatively new work) |
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1056 |
|
769 | 1057 |
\item we can prove its correctness\ldots (another video) |
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1058 |
\end{itemize} |
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1059 |
|
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1060 |
\end{frame} |
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1061 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1062 |
|
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1063 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
566 | 1064 |
\begin{frame}[c] |
1065 |
\frametitle{Negation of Regular Expr's} |
|
1066 |
||
1067 |
\begin{itemize} |
|
1068 |
\item \bl{$\sim{}r$} \hspace{6mm} (everything that \bl{$r$} cannot recognise)\medskip |
|
1069 |
\item \bl{$L(\sim{}r) \dn UNIV - L(r)$}\medskip |
|
1070 |
\item \bl{$nullable (\sim{}r) \dn not\, (nullable(r))$}\medskip |
|
1071 |
\item \bl{$der\,c\,(\sim{}r) \dn \;\sim{}(der\,c\,r)$} |
|
769 | 1072 |
\end{itemize}\bigskip\bigskip\medskip\pause |
566 | 1073 |
|
1074 |
Used often for recognising comments: |
|
1075 |
\[ |
|
1076 |
\bl{/ \cdot * \cdot (\sim{}([a\mbox{-}z]^* \cdot * \cdot / \cdot [a\mbox{-}z]^*)) \cdot * \cdot /} |
|
1077 |
\] |
|
1078 |
||
1079 |
\end{frame} |
|
1080 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1081 |
||
771 | 1082 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1083 |
\begin{frame}[c] |
|
1084 |
\frametitle{The Specification for Matching} |
|
566 | 1085 |
|
771 | 1086 |
\begin{bubble}[10cm] |
1087 |
\large |
|
1088 |
A regular expression \bl{$r$} matches a string~\bl{$s$} |
|
1089 |
provided: |
|
1090 |
\begin{center} |
|
1091 |
\bl{$s \in L(r)$} |
|
1092 |
\end{center}\medskip |
|
1093 |
\end{bubble} |
|
1094 |
||
1095 |
||
1096 |
\begin{center} |
|
1097 |
\onslide<2>{\bl{\large$\forall\,r\,s.\;$}} |
|
1098 |
\bl{$matcher\,s\,r$} \;if and only if\ \bl{$s \in L(r)$} |
|
1099 |
\end{center} |
|
1100 |
||
1101 |
||
1102 |
\end{frame} |
|
1103 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1104 |
||
1105 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1106 |
\begin{frame}[c] |
|
1107 |
\frametitle{nullable and \boldmath$der$} |
|
1108 |
||
1109 |
The central properties:\bigskip\bigskip |
|
1110 |
||
1111 |
\large |
|
1112 |
\begin{quote} |
|
1113 |
\onslide<3>{\bl{$\forall r.\phantom{\,c}\;$}}% |
|
1114 |
\bl{$nullable(r)$} \;if and only if\; \bl{$[] \in L(r)$} |
|
1115 |
\end{quote}\bigskip\bigskip\pause |
|
1116 |
||
1117 |
\begin{quote} |
|
1118 |
\onslide<3>{\bl{$\forall r\,c.\;$}}% |
|
1119 |
\bl{$L(der\,c\,r) \;=\; Der\,c\,(L(r))$} |
|
1120 |
\end{quote} |
|
1121 |
||
1122 |
\end{frame} |
|
1123 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
770 | 1124 |
|
566 | 1125 |
|
1126 |
||
764 | 1127 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
1128 |
\begin{frame}[t] |
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1129 |
\frametitle{Proofs about Rexps} |
17 | 1130 |
|
1131 |
Remember their inductive definition:\\[5cm] |
|
1132 |
||
1133 |
\begin{textblock}{6}(5,5) |
|
1134 |
\begin{tabular}{@ {}rrl} |
|
429
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
1135 |
\bl{$r$} & \bl{$::=$} & \bl{$\ZERO$}\\ |
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
1136 |
& \bl{$\mid$} & \bl{$\ONE$} \\ |
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1137 |
& \bl{$\mid$} & \bl{$c$} \\ |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1138 |
& \bl{$\mid$} & \bl{$r_1 \cdot r_2$}\\ |
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1139 |
& \bl{$\mid$} & \bl{$r_1 + r_2$} \\ |
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1140 |
& \bl{$\mid$} & \bl{$r^*$} \\ |
17 | 1141 |
\end{tabular} |
1142 |
\end{textblock} |
|
1143 |
||
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1144 |
If we want to prove something, say a property \bl{$P(r)$}, for all regular expressions \bl{$r$} then \ldots |
17 | 1145 |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1146 |
\end{frame} |
17 | 1147 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1148 |
||
1149 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1150 |
\begin{frame}[c] |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1151 |
\frametitle{Proofs about Rexp (2)} |
17 | 1152 |
|
1153 |
\begin{itemize} |
|
429
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
1154 |
\item \bl{$P$} holds for \bl{$\ZERO$}, \bl{$\ONE$} and \bl{c}\bigskip |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1155 |
\item \bl{$P$} holds for \bl{$r_1 + r_2$} under the assumption that \bl{$P$} already |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1156 |
holds for \bl{$r_1$} and \bl{$r_2$}.\bigskip |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1157 |
\item \bl{$P$} holds for \bl{$r_1 \cdot r_2$} under the assumption that \bl{$P$} already |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1158 |
holds for \bl{$r_1$} and \bl{$r_2$}.\bigskip |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1159 |
\item \bl{$P$} holds for \bl{$r^*$} under the assumption that \bl{$P$} already |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1160 |
holds for \bl{$r$}. |
17 | 1161 |
\end{itemize} |
1162 |
||
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1163 |
\end{frame} |
17 | 1164 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1165 |
||
1166 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1167 |
\begin{frame}[c] |
|
771 | 1168 |
\frametitle{Proofs about Rexp} |
17 | 1169 |
|
1170 |
Assume \bl{$P(r)$} is the property: |
|
1171 |
||
1172 |
\begin{center} |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1173 |
\bl{$nullable(r)$} if and only if \bl{$[] \in L(r)$} |
17 | 1174 |
\end{center} |
1175 |
||
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1176 |
\end{frame} |
17 | 1177 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1178 |
||
940 | 1179 |
% begin{frame}[c] |
1180 |
% \begin{mybox3}{} |
|
1181 |
% der c (r*) def = (der c r) $\cdot$ (r*)\smallskip\\ |
|
1182 |
% Why in the example (slide 19) the first step is: |
|
1183 |
% der a ((a $\cdot$ b) + b)* = (der a ((a $\cdot$ b) + b)) $\cdot$ r\smallskip\\ |
|
1184 |
% and not\smallskip\\ |
|
1185 |
% der a ((a $\cdot$ b) + b) = (der a ((a $\cdot$ b) + b)) · (r*) |
|
1186 |
% \end{mybox3} |
|
1187 |
% \end{frame} |
|
778 | 1188 |
|
940 | 1189 |
% \begin{frame}[c] |
1190 |
% \begin{mybox3}{} |
|
1191 |
% Would it be possible to find and go over a few examples from the |
|
1192 |
% Brzozowski Algorithm, as it doesn't seem to be as simple as it |
|
1193 |
% sounds? |
|
1194 |
% \end{mybox3} |
|
1195 |
% \end{frame} |
|
778 | 1196 |
|
940 | 1197 |
% \begin{frame}[c] |
1198 |
% \begin{mybox3}{} |
|
1199 |
% Is it possible to make a visual example of how using simp() function |
|
1200 |
% on a (a*)*.b regular expression reduces its runtime? If not it's |
|
1201 |
% fine. I am just very surprised that it is so efficient. |
|
1202 |
% \end{mybox3} |
|
1203 |
% \end{frame} |
|
778 | 1204 |
|
940 | 1205 |
% \begin{frame}[c] |
1206 |
% \begin{mybox3}{} |
|
1207 |
% Do you think the algorithm can be still improved (made faster)? |
|
1208 |
% \end{mybox3} |
|
1209 |
% \end{frame} |
|
778 | 1210 |
|
940 | 1211 |
% \begin{frame}[c] |
1212 |
% \begin{mybox3}{} |
|
1213 |
% Do the regular expression matchers in Python and Java 8 have more |
|
1214 |
% features than the one implemented in this module? Or is there |
|
1215 |
% another reason for their inefficiency? |
|
1216 |
% \end{mybox3} |
|
1217 |
% \end{frame} |
|
778 | 1218 |
|
940 | 1219 |
% \begin{frame}[c] |
1220 |
% \begin{mybox3}{} |
|
1221 |
% Will we discuss the broader Chomsky hierarchy of languages at some |
|
1222 |
% point? |
|
1223 |
% \end{mybox3} |
|
1224 |
% \end{frame} |
|
778 | 1225 |
|
1226 |
\begin{frame}<1-8>[c] |
|
1227 |
\end{frame} |
|
1228 |
||
842 | 1229 |
\begin{frame}[c] |
1230 |
\end{frame} |
|
1231 |
||
1232 |
\begin{frame}[c] |
|
1233 |
\end{frame} |
|
1234 |
||
1235 |
\begin{frame}[c] |
|
1236 |
\end{frame} |
|
1237 |
||
1238 |
\begin{frame}<1-10>[c] |
|
1239 |
\end{frame} |
|
1240 |
||
1241 |
||
1242 |
||
771 | 1243 |
\end{document} |
1244 |
% below are slides for proving. |
|
1245 |
||
17 | 1246 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1247 |
\begin{frame}[c] |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1248 |
\frametitle{Proofs about Rexp (4)} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1249 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1250 |
\begin{center} |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1251 |
\bl{\begin{tabular}{r@{\hspace{2mm}}c@{\hspace{2mm}}l} |
429
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
1252 |
$rev(\ZERO)$ & $\dn$ & $\ZERO$\\ |
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
1253 |
$rev(\ONE)$ & $\dn$ & $\ONE$\\ |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1254 |
$rev(c)$ & $\dn$ & $c$\\ |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1255 |
$rev(r_1 + r_2)$ & $\dn$ & $rev(r_1) + rev(r_2)$\\ |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1256 |
$rev(r_1 \cdot r_2)$ & $\dn$ & $rev(r_2) \cdot rev(r_1)$\\ |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1257 |
$rev(r^*)$ & $\dn$ & $rev(r)^*$\\ |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1258 |
\end{tabular}} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1259 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1260 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1261 |
We can prove |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1262 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1263 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1264 |
\bl{$L(rev(r)) = \{s^{-1} \;|\; s \in L(r)\}$} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1265 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1266 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1267 |
by induction on \bl{$r$}. |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1268 |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1269 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1270 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1271 |
|
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1272 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1273 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1274 |
\begin{frame}[c] |
638 | 1275 |
\frametitle{Correctness Proof \\[-1mm] |
1276 |
for our Matcher} |
|
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1277 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1278 |
\begin{itemize} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1279 |
\item We started from |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1280 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1281 |
\begin{center} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1282 |
\begin{tabular}{rp{4cm}} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1283 |
& \bl{$s \in L(r)$}\medskip\\ |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1284 |
\bl{$\Leftrightarrow$} & \bl{$[] \in \Ders\,s\,(L(r))$}\pause |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1285 |
\end{tabular} |
638 | 1286 |
\end{center}\bigskip |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1287 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1288 |
\item if we can show \bl{$\Ders\, s\,(L(r)) = L(\ders\,s\,r)$} we |
638 | 1289 |
have\bigskip |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1290 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1291 |
\begin{center} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1292 |
\begin{tabular}{rp{4cm}} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1293 |
\bl{$\Leftrightarrow$} & \bl{$[] \in L(\ders\,s\,r)$}\medskip\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1294 |
\bl{$\Leftrightarrow$} & \bl{$nullable(\ders\,s\,r)$}\medskip\\ |
764 | 1295 |
\bl{$\dn$} & \bl{$matcher\,s\,r$} |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1296 |
\end{tabular} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1297 |
\end{center} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1298 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1299 |
\end{itemize} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1300 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1301 |
\end{frame} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1302 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1303 |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1304 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1305 |
\begin{frame}[c] |
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1306 |
\frametitle{Proofs about Rexp (5)} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1307 |
|
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1308 |
Let \bl{$Der\,c\,A$} be the set defined as |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1309 |
|
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1310 |
\begin{center} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1311 |
\bl{$\Der\,c\,A \dn \{ s \;|\; c\!::\!s \in A\}$ } |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1312 |
\end{center} |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1313 |
|
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1314 |
We can prove |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1315 |
|
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1316 |
\begin{center} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1317 |
\bl{$L(\der\,c\,r) = \Der\,c\,(L(r))$} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1318 |
\end{center} |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1319 |
|
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1320 |
by induction on \bl{$r$}. |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1321 |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1322 |
\end{frame} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1323 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1324 |
|
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1325 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1326 |
\begin{frame}[c] |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1327 |
\frametitle{Proofs about Strings} |
17 | 1328 |
|
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1329 |
If we want to prove something, say a property \bl{$P(s)$}, for all strings \bl{$s$} then \ldots\bigskip |
17 | 1330 |
|
1331 |
\begin{itemize} |
|
1332 |
\item \bl{$P$} holds for the empty string, and\medskip |
|
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1333 |
\item \bl{$P$} holds for the string \bl{$c\!::\!s$} under the assumption that \bl{$P$} |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1334 |
already holds for \bl{$s$} |
17 | 1335 |
\end{itemize} |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1336 |
\end{frame} |
17 | 1337 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1338 |
||
19 | 1339 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1340 |
\begin{frame}[c] |
|
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1341 |
\frametitle{Proofs about Strings (2)} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1342 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1343 |
We can then prove |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1344 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1345 |
\begin{center} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1346 |
\bl{$\Ders\,s\,(L(r)) = L(\ders\,s\,r)$} |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1347 |
\end{center} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1348 |
|
19 | 1349 |
|
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1350 |
We can finally prove |
19 | 1351 |
|
1352 |
\begin{center} |
|
764 | 1353 |
\bl{$matcher\,s\,r$} if and only if \bl{$s \in L(r)$} |
19 | 1354 |
\end{center} |
1355 |
||
1356 |
||
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1357 |
\end{frame} |
19 | 1358 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
17 | 1359 |
|
436
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1360 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1361 |
\begin{frame}[c] |
770 | 1362 |
\frametitle{Coursework 1} |
1363 |
||
1364 |
%%\underline{Strand 1:} |
|
1365 |
||
1366 |
\begin{itemize} |
|
1367 |
\item Submission on Friday 16 October @ 18:00\medskip |
|
1368 |
\item source code needs to be submitted as well\medskip |
|
1369 |
\item you can re-use my Scala code from KEATS \\ |
|
1370 |
and use any programming language you like\medskip |
|
1371 |
\item \small https://nms.kcl.ac.uk/christian.urban/ProgInScala2ed.pdf\normalsize |
|
1372 |
\end{itemize} |
|
1373 |
||
1374 |
\end{frame} |
|
1375 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1376 |
||
1377 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1378 |
\begin{frame}[c] |
|
436
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1379 |
\frametitle{Epilogue} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1380 |
|
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1381 |
\footnotesize |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1382 |
\begin{center} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1383 |
\begin{tabular}{cc} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1384 |
\begin{tikzpicture} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1385 |
\begin{axis}[ |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
1386 |
title={\small{}Graph: \bl{$a^{?\{n\}} \cdot a^{\{n\}}$}}, |
436
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1387 |
xlabel={$n$}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1388 |
x label style={at={(1.04,0.0)}}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1389 |
ylabel={time in secs}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1390 |
enlargelimits=false, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1391 |
xmax=7100000, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1392 |
ytick={0,5,...,30}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1393 |
ymax=33, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1394 |
%scaled ticks=false, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1395 |
axis lines=left, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1396 |
width=5cm, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1397 |
height=5cm, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1398 |
legend entries={Scala V3, Scala V4}, |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
1399 |
legend style={at={(0.1,-0.2)},anchor=north}] |
436
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1400 |
\addplot[black,mark=square*,mark options={fill=white}] table {re3.data}; |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1401 |
\addplot[purple,mark=square*,mark options={fill=white}] table {re4.data}; |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1402 |
\end{axis} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1403 |
\end{tikzpicture} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1404 |
& |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1405 |
\begin{tikzpicture} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1406 |
\begin{axis}[ |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
1407 |
title={\small{}Graph: \bl{$(a^*)^* \cdot b$}}, |
436
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1408 |
xlabel={$n$}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1409 |
x label style={at={(1.09,0.0)}}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1410 |
ylabel={time in secs}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1411 |
enlargelimits=false, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1412 |
xmax=8100000, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1413 |
ytick={0,5,...,30}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1414 |
ymax=33, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1415 |
%scaled ticks=false, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1416 |
axis lines=left, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1417 |
width=5cm, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1418 |
height=5cm, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1419 |
legend entries={Scala V3, Scala V4}, |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
1420 |
legend style={at={(0.1,-0.2)},anchor=north}] |
436
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1421 |
\addplot[black,mark=square*,mark options={fill=white}] table {re3a.data}; |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1422 |
\addplot[purple,mark=square*,mark options={fill=white}] table {re4a.data}; |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1423 |
\end{axis} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1424 |
\end{tikzpicture} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1425 |
\end{tabular} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1426 |
\end{center} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1427 |
|
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1428 |
\only<2->{\footnotesize |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1429 |
\begin{textblock}{9}(0.5,8) |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1430 |
\begin{bubble}[11.8cm] |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1431 |
\lstinputlisting[numbers=none]{../progs/app52.scala} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1432 |
\end{bubble} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1433 |
\end{textblock}} |
510 | 1434 |
|
436
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1435 |
|
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1436 |
\end{frame} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1437 |
|
638 | 1438 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1439 |
\begin{frame}[c] |
|
1440 |
\frametitle{Another Homework Question} |
|
1441 |
||
1442 |
\begin{itemize} |
|
1443 |
\item How many basic regular expressions are there to match |
|
1444 |
the string \bl{$abcd$}\,?\pause |
|
1445 |
\item How many if they cannot include |
|
1446 |
\bl{$\ONE$} and \bl{$\ZERO$}\/?\pause |
|
1447 |
\item How many if they are also not |
|
1448 |
allowed to contain stars?\pause |
|
1449 |
\item How many if they are also |
|
1450 |
not allowed to contain \bl{$\_ + \_$}\/? |
|
1451 |
\end{itemize} |
|
1452 |
||
1453 |
\end{frame} |
|
1454 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
743 | 1455 |
|
1456 |
||
1457 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1458 |
\begin{frame}[c] |
|
1459 |
\frametitle{\begin{tabular}{c}\\[3cm]\huge\alert{Questions?}\end{tabular}} |
|
1460 |
||
764 | 1461 |
%\bigskip |
1462 |
%homework (written exam 80\%)\\ |
|
1463 |
%coursework (20\%; first one today)\\ |
|
1464 |
%submission Fridays @ 18:00 -- accepted until Mondays |
|
743 | 1465 |
\mbox{} |
1466 |
\end{frame} |
|
1467 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1468 |
||
1469 |
||
1470 |
||
1471 |
||
1472 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1473 |
\begin{frame}[c] |
|
1474 |
\frametitle{Last Week} |
|
1475 |
||
1476 |
Last week I showed you a regular expression matcher |
|
1477 |
that works provably correct in all cases (we only |
|
1478 |
started with the proving part though) |
|
1479 |
||
1480 |
\begin{center} |
|
764 | 1481 |
\bl{$matcher\,s\,r$} \;\;if and only if \;\; \bl{$s \in L(r)$} |
743 | 1482 |
\end{center}\bigskip\bigskip |
1483 |
||
1484 |
\small |
|
1485 |
\textcolor{gray}{\mbox{}\hfill{}by Janusz Brzozowski (1964)} |
|
1486 |
||
1487 |
\end{frame} |
|
1488 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1489 |
||
1490 |
||
1491 |
||
1492 |
||
1493 |
||
764 | 1494 |
|
743 | 1495 |
|
1496 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1497 |
\begin{frame}[c] |
|
1498 |
\frametitle{Proofs about Rexp} |
|
1499 |
||
1500 |
\begin{itemize} |
|
1501 |
\item \bl{$P$} holds for \bl{$\ZERO$}, \bl{$\ONE$} and \bl{c}\bigskip |
|
1502 |
\item \bl{$P$} holds for \bl{$r_1 + r_2$} under the assumption that \bl{$P$} already |
|
1503 |
holds for \bl{$r_1$} and \bl{$r_2$}.\bigskip |
|
1504 |
\item \bl{$P$} holds for \bl{$r_1 \cdot r_2$} under the assumption that \bl{$P$} already |
|
1505 |
holds for \bl{$r_1$} and \bl{$r_2$}.\bigskip |
|
1506 |
\item \bl{$P$} holds for \bl{$r^*$} under the assumption that \bl{$P$} already |
|
1507 |
holds for \bl{$r$}. |
|
1508 |
\end{itemize} |
|
1509 |
||
1510 |
\end{frame} |
|
1511 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1512 |
||
1513 |
||
1514 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1515 |
\begin{frame}[c] |
|
1516 |
||
1517 |
We proved |
|
1518 |
||
1519 |
\begin{center} |
|
1520 |
\bl{$nullable(r)$} \;if and only if\; \bl{$[] \in L(r)$} |
|
1521 |
\end{center} |
|
1522 |
||
1523 |
by induction on the regular expression \bl{$r$}.\bigskip\pause |
|
1524 |
||
1525 |
\begin{center} |
|
1526 |
{\huge\bf\alert{Any Questions?}} |
|
1527 |
\end{center} |
|
1528 |
||
1529 |
\end{frame} |
|
1530 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1531 |
||
1532 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1533 |
\begin{frame}[c] |
|
1534 |
\frametitle{\begin{tabular}{c}Proofs about Natural\\[-1mm] Numbers and Strings\end{tabular}} |
|
1535 |
||
1536 |
\begin{itemize} |
|
1537 |
\item \bl{$P$} holds for \bl{$0$} and |
|
1538 |
\item \bl{$P$} holds for \bl{$n + 1$} under the assumption that \bl{$P$} already |
|
1539 |
holds for \bl{$n$} |
|
1540 |
\end{itemize}\bigskip |
|
1541 |
||
1542 |
\begin{itemize} |
|
1543 |
\item \bl{$P$} holds for \bl{$[]$} and |
|
1544 |
\item \bl{$P$} holds for \bl{$c\!::\!s$} under the assumption that \bl{$P$} already |
|
1545 |
holds for \bl{$s$} |
|
1546 |
\end{itemize} |
|
1547 |
||
1548 |
\end{frame} |
|
1549 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1550 |
||
1551 |
||
1552 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1553 |
\begin{frame}[c] |
|
1554 |
\frametitle{Correctness Proof \\[-1mm] |
|
1555 |
for our Matcher} |
|
1556 |
||
1557 |
\begin{itemize} |
|
1558 |
\item We started from |
|
1559 |
||
1560 |
\begin{center} |
|
1561 |
\begin{tabular}{rp{4cm}} |
|
1562 |
& \bl{$s \in L(r)$}\medskip\\ |
|
1563 |
\bl{$\Leftrightarrow$} & \bl{$[] \in \Ders\,s\,(L(r))$}\pause |
|
1564 |
\end{tabular} |
|
1565 |
\end{center}\bigskip |
|
1566 |
||
1567 |
\item \textbf{\alert{if}} we can show \bl{$\Ders\, s\,(L(r)) = L(\ders\,s\,r)$} we |
|
1568 |
have\bigskip |
|
1569 |
||
1570 |
\begin{center} |
|
1571 |
\begin{tabular}{rp{4cm}} |
|
1572 |
\bl{$\Leftrightarrow$} & \bl{$[] \in L(\ders\,s\,r)$}\medskip\\ |
|
1573 |
\bl{$\Leftrightarrow$} & \bl{$nullable(\ders\,s\,r)$}\medskip\\ |
|
764 | 1574 |
\bl{$\dn$} & \bl{$matcher\,s\,r$} |
743 | 1575 |
\end{tabular} |
1576 |
\end{center} |
|
1577 |
||
1578 |
\end{itemize} |
|
1579 |
||
1580 |
\end{frame} |
|
1581 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1582 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1583 |
\begin{frame}[c] |
|
1584 |
||
1585 |
We need to prove |
|
1586 |
||
1587 |
\begin{center} |
|
1588 |
\bl{$L(der\,c\,r) = Der\,c\,(L(r))$} |
|
1589 |
\end{center} |
|
1590 |
||
1591 |
also by induction on the regular expression \bl{$r$}. |
|
1592 |
\end{frame} |
|
1593 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1594 |
||
1595 |
||
1596 |
||
638 | 1597 |
|
7 | 1598 |
\end{document} |
1599 |
||
1600 |
%%% Local Variables: |
|
1601 |
%%% mode: latex |
|
1602 |
%%% TeX-master: t |
|
1603 |
%%% End: |
|
1604 |