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