author | Christian Urban <urbanc@in.tum.de> |
Thu, 28 Nov 2019 08:18:57 +0000 | |
changeset 701 | 681c36b2af27 |
parent 646 | 2abd285c66d1 |
child 743 | 6acabeecdf75 |
permissions | -rw-r--r-- |
638 | 1 |
% !TEX program = xelatex |
7 | 2 |
\documentclass[dvipsnames,14pt,t]{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 |
|
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
8 |
\hfuzz=220pt |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
9 |
|
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
10 |
\lstset{language=Scala, |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
11 |
style=mystyle, |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
12 |
numbersep=0pt, |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
13 |
numbers=none, |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
14 |
xleftmargin=0mm} |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
15 |
|
398
c8ce95067c1a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
345
diff
changeset
|
16 |
\pgfplotsset{compat=1.12} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
17 |
|
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
18 |
\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
|
19 |
|
7 | 20 |
% beamer stuff |
429
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
21 |
\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
|
22 |
|
7 | 23 |
|
24 |
\begin{document} |
|
25 |
||
26 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
261
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
27 |
\begin{frame}[t] |
7 | 28 |
\frametitle{% |
29 |
\begin{tabular}{@ {}c@ {}} |
|
30 |
\\[-3mm] |
|
429
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
31 |
\LARGE Compilers and \\[-1mm] |
16 | 32 |
\LARGE Formal Languages (2)\\[3mm] |
7 | 33 |
\end{tabular}} |
34 |
||
261
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
35 |
\normalsize |
7 | 36 |
\begin{center} |
37 |
\begin{tabular}{ll} |
|
638 | 38 |
Email: & christian.urban at kcl.ac.uk\\ |
39 |
Office Hours: & Thursdays 12 -- 14\\ |
|
40 |
Location: & N7.07 (North Wing, Bush House)\\ |
|
41 |
Slides \& Progs: & KEATS (also homework is there)\\ |
|
7 | 42 |
\end{tabular} |
43 |
\end{center} |
|
44 |
||
261
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
45 |
\end{frame} |
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
46 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
7 | 47 |
|
48 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
565 | 49 |
\begin{frame}[t] |
630 | 50 |
\frametitle{ |
565 | 51 |
Lets Implement an Efficient\\[-2mm] |
52 |
Regular Expression Matcher} |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
53 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
54 |
\footnotesize |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
55 |
\begin{center} |
565 | 56 |
{\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
|
57 |
\begin{tabular}{@{}cc@{}} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
58 |
\begin{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
59 |
\begin{axis}[ |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
60 |
xlabel={$n$}, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
61 |
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
|
62 |
ylabel={time in secs}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
63 |
enlargelimits=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
64 |
xtick={0,5,...,30}, |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
65 |
xmax=33, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
66 |
ymax=35, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
67 |
ytick={0,5,...,30}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
68 |
scaled ticks=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
69 |
axis lines=left, |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
70 |
width=5cm, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
71 |
height=4.5cm, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
72 |
legend entries={Python,Ruby}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
73 |
legend pos=north west, |
514 | 74 |
legend cell align=left] |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
75 |
\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
|
76 |
\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
|
77 |
\end{axis} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
78 |
\end{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
79 |
& |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
80 |
\begin{tikzpicture} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
81 |
\begin{axis}[ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
82 |
xlabel={$n$}, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
83 |
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
|
84 |
ylabel={time in secs}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
85 |
enlargelimits=false, |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
86 |
xtick={0,5000,...,10000}, |
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
87 |
xmax=11500, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
88 |
ymax=35, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
89 |
ytick={0,5,...,30}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
90 |
scaled ticks=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
91 |
axis lines=left, |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
92 |
width=5cm, |
514 | 93 |
height=4.5cm, |
94 |
legend entries={Scala V2,Scala V3}, |
|
565 | 95 |
legend pos=north east, |
514 | 96 |
legend cell align=left] |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
97 |
\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
|
98 |
\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
|
99 |
\end{axis} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
100 |
\end{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
101 |
\end{tabular} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
102 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
103 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
104 |
\small |
638 | 105 |
In the handouts is a similar graph for \bl{$(a^*)^* \cdot b$} and Java 8, |
106 |
JavaScript and Python. |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
107 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
108 |
\end{frame} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
109 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
110 |
|
512 | 111 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
638 | 112 |
%\begin{frame}[c] |
113 |
%\frametitle{Evil Regular Expressions} |
|
114 |
% |
|
115 |
%\begin{itemize} |
|
116 |
%\item \alert{R}egular \alert{e}xpression \alert{D}enial \alert{o}f \alert{S}ervice (ReDoS)\bigskip |
|
117 |
%\item Evil regular expressions\medskip |
|
118 |
%\begin{itemize} |
|
119 |
%\item \bl{$a^{?\{n\}} \cdot a^{\{n\}}$} |
|
120 |
%\item \bl{$(a^*)^*$} |
|
121 |
%\item \bl{$([a$\,-\,$z]^+)^*$} |
|
122 |
%\item \bl{$(a + a \cdot a)^*$} |
|
123 |
%\item \bl{$(a + a^?)^*$} |
|
124 |
%\end{itemize} |
|
125 |
% |
|
126 |
%\item sometimes also called \alert{catastrophic backtracking}\bigskip |
|
127 |
%\item \small\ldots I hope you have watched the video by the |
|
128 |
% StackExchange engineer |
|
129 |
%\end{itemize} |
|
130 |
% |
|
131 |
%\end{frame} |
|
512 | 132 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
133 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
134 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
135 |
\begin{frame}[c] |
638 | 136 |
\frametitle{(Basic) Regular Expressions} |
137 |
||
138 |
Their inductive definition: |
|
139 |
||
140 |
\begin{center} |
|
141 |
\begin{tabular}{@ {}rrl@ {\hspace{13mm}}l} |
|
142 |
\bl{$r$} & \bl{$::=$} & \bl{$\ZERO$} & nothing\\ |
|
143 |
& \bl{$\mid$} & \bl{$\ONE$} & empty string / \pcode{""} / $[]$\\ |
|
144 |
& \bl{$\mid$} & \bl{$c$} & character\\ |
|
145 |
& \bl{$\mid$} & \bl{$r_1 + r_2$} & alternative / choice\\ |
|
146 |
& \bl{$\mid$} & \bl{$r_1 \cdot r_2$} & sequence\\ |
|
147 |
& \bl{$\mid$} & \bl{$r^*$} & star (zero or more)\\ |
|
148 |
\end{tabular} |
|
149 |
\end{center} |
|
150 |
\vspace{\fill} |
|
151 |
||
152 |
Q: \;What about \;\bl{$r \cdot 0$} \; ? |
|
153 |
\end{frame} |
|
154 |
||
155 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
156 |
\begin{frame}[c] |
|
157 |
\frametitle{Languages (Sets of Strings)} |
|
16 | 158 |
|
261
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
159 |
\begin{itemize} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
160 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
161 |
\item A \alert{\bf Language} is a set of strings, for example\medskip |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
162 |
\begin{center} |
638 | 163 |
\bl{$\{[], hello, foobar, a, abc\}$} |
261
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
164 |
\end{center}\bigskip |
16 | 165 |
|
638 | 166 |
\item \alert{\bf Concatenation} for strings and languages |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
167 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
168 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
169 |
\begin{tabular}{rcl} |
638 | 170 |
\bl{$foo\;@\;bar$} & \bl{$=$} & \bl{$foobar$}\medskip\\ |
171 |
\bl{$A\;@\;B$} & \bl{$\dn$} & \bl{$\{ s_1\,@\,s_2 \;\mid\; s_1 \in A \wedge s_2 \in B\}$} |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
172 |
\end{tabular} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
173 |
\end{center} |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
174 |
\bigskip |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
175 |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
176 |
\small |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
177 |
\item [] For example \bl{$A = \{foo, bar\}$}, \bl{$B = \{a, b\}$} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
178 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
179 |
\[ |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
180 |
\bl{A \,@\, B = \{fooa, foob, bara, barb\}} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
181 |
\] |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
182 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
183 |
\end{itemize} |
638 | 184 |
\end{frame} |
185 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
186 |
||
187 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
188 |
\begin{frame}[c] |
|
189 |
\frametitle{Two Corner Cases} |
|
190 |
||
191 |
\Large |
|
192 |
\begin{center} |
|
193 |
\bl{$A \,@\, \{[]\} = \;?$}\bigskip\bigskip\pause\\ |
|
194 |
\bl{$A \,@\, \{\} = \;?$} |
|
195 |
\end{center} |
|
196 |
||
197 |
\end{frame} |
|
198 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
199 |
||
200 |
||
201 |
||
202 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
203 |
\begin{frame}[c] |
|
204 |
\frametitle{ |
|
205 |
The Meaning of a\\[-2mm] |
|
206 |
Regular Expression} |
|
207 |
||
208 |
...all the strings a regular expression can match. |
|
209 |
||
210 |
\begin{center} |
|
211 |
\begin{tabular}{rcl} |
|
212 |
\bl{$L(\ZERO)$} & \bl{$\dn$} & \bl{$\{\}$}\\ |
|
213 |
\bl{$L(\ONE)$} & \bl{$\dn$} & \bl{$\{[]\}$}\\ |
|
214 |
\bl{$L(c)$} & \bl{$\dn$} & \bl{$\{[c]\}$}\\ |
|
215 |
\bl{$L(r_1 + r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\ |
|
216 |
\bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \,@\, L(r_2)$}\\ |
|
217 |
\bl{$L(r^*)$} & \bl{$\dn$} & \\ |
|
218 |
\end{tabular} |
|
219 |
\end{center} |
|
220 |
||
221 |
\begin{textblock}{14}(1.5,13.5)\small |
|
222 |
\bl{$L$} is a function from regular expressions to |
|
223 |
sets of strings (languages):\smallskip\\ |
|
224 |
\bl{\quad$L$ : Rexp $\Rightarrow$ Set$[$String$]$} |
|
225 |
\end{textblock} |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
226 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
227 |
\end{frame} |
638 | 228 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
229 |
||
230 |
||
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
231 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
232 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
233 |
\begin{frame}[c] |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
234 |
\frametitle{The Power Operation} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
235 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
236 |
\begin{itemize} |
512 | 237 |
\item The \alert{\textbf{\boldmath$n$th Power}} of a language: |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
238 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
239 |
\begin{center} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
240 |
\begin{tabular}{lcl} |
431 | 241 |
\bl{$A^0$} & \bl{$\dn$} & \bl{$\{[]\}$}\\ |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
242 |
\bl{$A^{n+1}$} & \bl{$\dn$} & \bl{$A \,@\, A^n$} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
243 |
\end{tabular} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
244 |
\end{center}\bigskip |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
245 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
246 |
\item[] For example |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
247 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
248 |
\begin{center} |
514 | 249 |
\begin{tabular}{lcl@{\hspace{10mm}}l} |
250 |
\bl{$A^4$} & \bl{$=$} & \bl{$A \,@\, A \,@\, A \,@\, A$} & \bl{$(@\,\{[]\})$}\\ |
|
251 |
\bl{$A^1$} & \bl{$=$} & \bl{$A$} & \bl{$(@\,\{[]\})$}\\ |
|
431 | 252 |
\bl{$A^0$} & \bl{$=$} & \bl{$\{[]\}$}\\ |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
253 |
\end{tabular} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
254 |
\end{center} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
255 |
|
261
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
256 |
\end{itemize} |
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
257 |
|
24531cfaa36a
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
258 |
\end{frame} |
16 | 259 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
260 |
||
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
261 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
262 |
\begin{frame}[c] |
638 | 263 |
\frametitle{Homework Question} |
264 |
||
265 |
\begin{itemize} |
|
266 |
\item Say \bl{$A = \{[a],[b],[c],[d]\}$}.\bigskip |
|
267 |
||
268 |
\item[] |
|
269 |
How many strings are in \bl{$A^4$}\,? |
|
270 |
\bigskip\medskip\pause |
|
271 |
||
272 |
||
273 |
\item[] |
|
274 |
What if \bl{$A = \{[a],[b],[c],[]\}$};\\ |
|
275 |
how many strings are then in \bl{$A^4$}\,? |
|
276 |
\end{itemize} |
|
277 |
||
336
7c80b9b6f713
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
335
diff
changeset
|
278 |
\end{frame} |
638 | 279 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
336
7c80b9b6f713
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
335
diff
changeset
|
280 |
|
7c80b9b6f713
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
335
diff
changeset
|
281 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
7c80b9b6f713
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
335
diff
changeset
|
282 |
\begin{frame}[c] |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
283 |
\frametitle{The Star Operation} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
284 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
285 |
\begin{itemize} |
514 | 286 |
\item The \alert{\bf Kleene Star} of a \underline{language}: |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
287 |
\bigskip |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
288 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
289 |
\begin{center} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
290 |
\begin{tabular}{c} |
431 | 291 |
\bl{$A\star \dn \bigcup_{0\le n} A^n$} |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
292 |
\end{tabular} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
293 |
\end{center}\bigskip |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
294 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
295 |
\item[] This expands to |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
296 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
297 |
\[ |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
298 |
\bl{A^0 \cup A^1 \cup A^2 \cup A^3 \cup A^4 \cup \ldots} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
299 |
\] |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
300 |
|
565 | 301 |
or |
302 |
||
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
303 |
\small |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
304 |
\[ |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
305 |
\bl{\{[]\} \;\cup\; A \;\cup\; A\,@\,A \;\cup\; |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
306 |
A\,@\,A\,@\,A \;\cup\; A\,@\,A\,@\,A\,@\,A \cup \ldots} |
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 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
309 |
\end{itemize} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
310 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
311 |
\end{frame} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
312 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
313 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
314 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
315 |
\begin{frame}[c] |
565 | 316 |
\frametitle{ |
317 |
The Meaning of a\\[-2mm] |
|
318 |
Regular Expression} |
|
507 | 319 |
|
638 | 320 |
...all the strings a regular expression can match. |
321 |
||
322 |
\begin{center} |
|
507 | 323 |
\begin{tabular}{rcl} |
324 |
\bl{$L(\ZERO)$} & \bl{$\dn$} & \bl{$\{\}$}\\ |
|
325 |
\bl{$L(\ONE)$} & \bl{$\dn$} & \bl{$\{[]\}$}\\ |
|
326 |
\bl{$L(c)$} & \bl{$\dn$} & \bl{$\{[c]\}$}\\ |
|
327 |
\bl{$L(r_1 + r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\ |
|
638 | 328 |
\bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \,@\, L(r_2)$}\\ |
507 | 329 |
\bl{$L(r^*)$} & \bl{$\dn$} & \bl{$(L(r))\star \quad\dn \bigcup_{0 \le n} L(r)^n$}\\ |
330 |
\end{tabular} |
|
638 | 331 |
\end{center} |
507 | 332 |
|
638 | 333 |
%\begin{textblock}{9}(6,12)\small |
334 |
%\bl{$L$} is a function from regular expressions to |
|
335 |
%sets of strings (languages):\smallskip\\ |
|
336 |
%\bl{$L$ : Rexp $\Rightarrow$ Set$[$String$]$} |
|
337 |
%\end{textblock} |
|
507 | 338 |
|
339 |
\end{frame} |
|
340 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
341 |
||
638 | 342 |
|
343 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
344 |
\begin{frame}[c] |
|
345 |
\frametitle{ |
|
346 |
When Are Two Regular\\[-1mm] |
|
347 |
Expressions Equivalent?} |
|
348 |
||
349 |
\begin{bubble}[10cm] |
|
350 |
\large |
|
351 |
Two regular expressions \bl{$r_1$} and \bl{$r_2$} are equivalent |
|
352 |
provided:\medskip |
|
353 |
\begin{center} |
|
354 |
\bl{$r_1 \equiv r_2 \;\;\dn\;\; L(r_1) = L(r_2)$} |
|
355 |
\end{center}\medskip |
|
356 |
\end{bubble} |
|
357 |
||
358 |
\end{frame} |
|
359 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
360 |
||
361 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
362 |
\begin{frame}[c] |
|
363 |
\frametitle{Some Concrete Equivalences} |
|
364 |
||
365 |
\begin{center} |
|
366 |
\bl{\begin{tabular}{rcl} |
|
367 |
$(a + b) + c$ & $\equiv$ & $a + (b + c)$\\ |
|
368 |
$a + a$ & $\equiv$ & $a$\\ |
|
369 |
$a + b$ & $\equiv$ & $b + a$\\ |
|
370 |
$(a \cdot b) \cdot c$ & $\equiv$ & $a \cdot (b \cdot c)$\\ |
|
371 |
$c \cdot (a + b)$ & $\equiv$ & $(c \cdot a) + (c \cdot b)$\bigskip\bigskip\\\pause |
|
372 |
$a \cdot a$ & $\not\equiv$ & $a$\\ |
|
373 |
$a + (b \cdot c)$ & $\not\equiv$ & $(a + b) \cdot (a + c)$\\ |
|
374 |
\end{tabular}} |
|
375 |
\end{center} |
|
376 |
||
377 |
\end{frame} |
|
378 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
379 |
||
380 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
381 |
\begin{frame}[c] |
|
382 |
\frametitle{Some Corner Cases} |
|
383 |
||
384 |
\begin{center} |
|
385 |
\bl{\begin{tabular}{rcl} |
|
386 |
$a \cdot \ZERO$ & $\not\equiv$ & $a$\\ |
|
387 |
$a + \ONE$ & $\not\equiv$ & $a$\\ |
|
388 |
$\ONE$ & $\equiv$ & $\ZERO^*$\\ |
|
389 |
$\ONE^*$ & $\equiv$ & $\ONE$\\ |
|
390 |
$\ZERO^*$ & $\not\equiv$ & $\ZERO$\\ |
|
391 |
\end{tabular}} |
|
392 |
\end{center} |
|
393 |
||
394 |
\end{frame} |
|
395 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
396 |
||
397 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
398 |
\begin{frame}[c] |
|
399 |
\frametitle{Some Simplification Rules} |
|
400 |
||
401 |
\begin{center} |
|
402 |
\bl{\begin{tabular}{rcl} |
|
403 |
$r + \ZERO$ & $\equiv$ & $r$\\ |
|
404 |
$\ZERO + r$ & $\equiv$ & $r$\\ |
|
405 |
$r \cdot \ONE$ & $\equiv$ & $r$\\ |
|
406 |
$\ONE \cdot r$ & $\equiv$ & $r$\\ |
|
407 |
$r \cdot \ZERO$ & $\equiv$ & $\ZERO$\\ |
|
408 |
$\ZERO \cdot r$ & $\equiv$ & $\ZERO$\\ |
|
409 |
$r + r$ & $\equiv$ & $r$ |
|
410 |
\end{tabular}} |
|
411 |
\end{center} |
|
412 |
||
413 |
\end{frame} |
|
414 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
415 |
||
416 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
417 |
\begin{frame}[c] |
|
418 |
\frametitle{The Specification for Matching} |
|
419 |
||
420 |
\begin{bubble}[10cm] |
|
421 |
\large |
|
422 |
A regular expression \bl{$r$} matches a string~\bl{$s$} |
|
423 |
provided: |
|
424 |
\begin{center} |
|
425 |
\bl{$s \in L(r)$} |
|
426 |
\end{center}\medskip |
|
427 |
\end{bubble} |
|
428 |
||
429 |
\bigskip\bigskip |
|
430 |
||
431 |
\ldots and the point of the this lecture is to decide this problem as |
|
432 |
fast as possible (unlike Python, Ruby, Java etc) |
|
433 |
||
434 |
\end{frame} |
|
435 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
436 |
||
437 |
||
566 | 438 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
439 |
\begin{frame}[c] |
|
440 |
\frametitle{\begin{tabular}{c}\\[3cm]\huge\alert{Questions?}\end{tabular}} |
|
441 |
||
442 |
\bigskip |
|
443 |
homework (written exam 80\%)\\ |
|
444 |
coursework (20\%; first one today)\\ |
|
567 | 445 |
submission Fridays @ 18:00 -- accepted until Mondays |
566 | 446 |
\mbox{} |
447 |
\end{frame} |
|
448 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
449 |
||
450 |
||
507 | 451 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
565 | 452 |
\begin{frame}[t] |
453 |
\frametitle{Semantic Derivative\\[5mm]} |
|
454 |
||
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
455 |
\begin{itemize} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
456 |
\item The \alert{\bf Semantic Derivative} of a |
565 | 457 |
\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
|
458 |
\bigskip |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
459 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
460 |
\begin{center} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
461 |
\bl{$\Der\,c\,A \dn \{ s \;|\; c\!::\!s \in A\}$ } |
565 | 462 |
\end{center}\bigskip |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
463 |
|
630 | 464 |
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
|
465 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
466 |
\begin{center} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
467 |
\bl{\begin{tabular}{l@{\hspace{2mm}}c@{\hspace{2mm}}l} |
630 | 468 |
$\Der\,f\,A$ & $=$ & $\{\mathit{oo}, \mathit{rak}\}$\\ |
469 |
$\Der\,b\,A$ & $=$ & $\{\mathit{ar}\}$\\ |
|
565 | 470 |
$\Der\,a\,A$ & $=$ & $\{\}$\pause |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
471 |
\end{tabular}} |
638 | 472 |
\end{center}\medskip |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
473 |
|
630 | 474 |
|
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
475 |
We can extend this definition to strings |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
476 |
\[ |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
477 |
\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
|
478 |
\] |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
479 |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
480 |
\end{itemize} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
481 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
482 |
\end{frame} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
483 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
484 |
|
512 | 485 |
|
486 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
487 |
\begin{frame}[c] |
|
573 | 488 |
\frametitle{\mbox{Brzozowski's Algorithm (1)}} |
11 | 489 |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
490 |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
491 |
\ldots{}whether a regular expression can match the empty string: |
11 | 492 |
\begin{center} |
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
493 |
\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
|
494 |
\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
|
495 |
\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
|
496 |
\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
|
497 |
\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
|
498 |
\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
|
499 |
\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
|
500 |
\end{tabular} |
16 | 501 |
\end{center} |
502 |
||
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
503 |
\end{frame} |
11 | 504 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
505 |
||
506 |
||
507 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
508 |
\begin{frame}[c] |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
509 |
\frametitle{The Derivative of a Rexp} |
7 | 510 |
|
511 |
\large |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
512 |
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
|
513 |
expression that matches just \bl{$s$}?\bigskip\bigskip\bigskip\bigskip |
7 | 514 |
|
515 |
\small |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
516 |
\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
|
517 |
\end{frame} |
7 | 518 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
519 |
||
520 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
521 |
\begin{frame}[c] |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
522 |
\frametitle{The Derivative of a Rexp} |
7 | 523 |
|
524 |
\begin{center} |
|
525 |
\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
|
526 |
\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
|
527 |
\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
|
528 |
\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
|
529 |
\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
|
530 |
\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
|
531 |
& & \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
|
532 |
& & \bl{else $(\der\, c\, r_1) \cdot r_2$}\\ |
638 | 533 |
\bl{$\der\, c\, (r^*)$} & \bl{$\dn$} & \bl{$(\der\,c\,r) \cdot (r^*)$} &\medskip\bigskip\\\pause |
7 | 534 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
535 |
\bl{$\ders\, []\, r$} & \bl{$\dn$} & \bl{$r$} & \\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
536 |
\bl{$\ders\, (c\!::\!s)\, r$} & \bl{$\dn$} & \bl{$\ders\,s\,(\der\,c\,r)$} & \\ |
7 | 537 |
\end{tabular} |
538 |
\end{center} |
|
539 |
||
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
540 |
\end{frame} |
7 | 541 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
542 |
||
543 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
544 |
\begin{frame}[c] |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
545 |
\frametitle{Examples} |
7 | 546 |
|
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
547 |
Given \bl{$r \dn ((a \cdot b) + b)^*$} what is |
7 | 548 |
|
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
549 |
\begin{center} |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
550 |
\begin{tabular}{l} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
551 |
\bl{$\der\,a\,r =\;?$}\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
552 |
\bl{$\der\,b\,r =\;?$}\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
553 |
\bl{$\der\,c\,r =\;?$} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
554 |
\end{tabular} |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
555 |
\end{center} |
7 | 556 |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
557 |
\end{frame} |
7 | 558 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
559 |
||
17 | 560 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
431 | 561 |
\begin{frame}[c] |
565 | 562 |
\frametitle{\mbox{The Brzozowski Algorithm}} |
431 | 563 |
|
564 |
\begin{center} |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
565 |
\begin{tabular}{l} |
565 | 566 |
\bl{$\textit{matches}\,r\,s \dn \textit{nullable}(\ders\;s\;r)$} |
431 | 567 |
\end{tabular} |
568 |
\end{center} |
|
569 |
||
570 |
||
571 |
\end{frame} |
|
572 |
%%%%%%%%%%%%%%%%% |
|
573 |
||
574 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
17 | 575 |
\begin{frame}[t] |
565 | 576 |
\frametitle{Brzozowski: An Example} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
577 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
578 |
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
|
579 |
\begin{center} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
580 |
\begin{tabular}{@{}rl@{}l@{}} |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
581 |
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
|
582 |
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
|
583 |
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
|
584 |
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
|
585 |
& test whether \bl{$r_4$} can recognise\\ |
565 | 586 |
& the empty string\medskip\\ |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
587 |
Output: & result of the test\\ |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
588 |
& $\Rightarrow \bl{\textit{true}} \,\text{or}\, |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
589 |
\bl{\textit{false}}$\\ |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
590 |
\end{tabular} |
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 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
593 |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
594 |
\end{frame} |
263
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 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
597 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
598 |
\begin{frame}[c] |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
599 |
\frametitle{The Idea of the Algorithm} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
600 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
601 |
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
|
602 |
expression \bl{$r_1$} then\medskip |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
603 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
604 |
\begin{enumerate} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
605 |
\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
|
606 |
\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
|
607 |
\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
|
608 |
\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
|
609 |
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
|
610 |
\end{enumerate} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
611 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
612 |
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
|
613 |
\end{frame} |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
614 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
615 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
616 |
|
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
617 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
618 |
\begin{frame}[c] |
638 | 619 |
\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
|
620 |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
621 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
622 |
\begin{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
623 |
\begin{axis}[ |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
624 |
xlabel={$n$}, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
625 |
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
|
626 |
ylabel={time in secs}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
627 |
enlargelimits=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
628 |
xtick={0,5,...,30}, |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
629 |
xmax=31, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
630 |
ytick={0,5,...,30}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
631 |
scaled ticks=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
632 |
axis lines=left, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
633 |
width=7cm, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
634 |
height=7cm, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
635 |
legend entries={Python,Ruby,Scala V1}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
636 |
legend pos=outer north east, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
637 |
legend cell align=left |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
638 |
] |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
639 |
\addplot[blue,mark=*, mark options={fill=white}] |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
640 |
table {re-python.data}; |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
641 |
\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
|
642 |
table {re-ruby.data}; |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
643 |
\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
|
644 |
table {re1.data}; |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
645 |
\end{axis} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
646 |
\end{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
647 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
648 |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
649 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
650 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
651 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
652 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
565 | 653 |
\begin{frame}[t] |
654 |
\frametitle{A Problem\medskip} |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
655 |
|
345
0922b3e01289
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
342
diff
changeset
|
656 |
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
|
657 |
sequence regular expression: |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
658 |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
659 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
660 |
\begin{tabular}{rl} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
661 |
1: & \bl{$a$}\\ |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
662 |
2: & \bl{$a\cdot a$}\\ |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
663 |
3: & \bl{$a\cdot a\cdot a$}\\ |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
664 |
& \ldots\\ |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
665 |
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
|
666 |
& \ldots\\ |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
667 |
20: |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
668 |
\end{tabular} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
669 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
670 |
|
345
0922b3e01289
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
342
diff
changeset
|
671 |
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
|
672 |
as \bl{$a + \ONE$}. |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
673 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
674 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
675 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
676 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
677 |
\begin{frame}[c] |
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
678 |
\frametitle{Solving the Problem} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
679 |
|
514 | 680 |
What happens if we extend our regular expressions with explicit |
681 |
constructors |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
682 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
683 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
684 |
\begin{tabular}{rcl} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
685 |
\bl{$r$} & \bl{$::=$} & \bl{\ldots}\\ |
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
686 |
& \bl{$\mid$} & \bl{$r^{\{n\}}$}\\ |
345
0922b3e01289
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
342
diff
changeset
|
687 |
& \bl{$\mid$} & \bl{$r^?$} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
688 |
\end{tabular} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
689 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
690 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
691 |
What is their meaning?\\ |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
692 |
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
|
693 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
694 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
695 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
696 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
697 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
698 |
\begin{frame}[t] |
638 | 699 |
\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
|
700 |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
701 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
702 |
\begin{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
703 |
\begin{axis}[ |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
704 |
xlabel={$n$}, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
705 |
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
|
706 |
ylabel={time in secs}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
707 |
enlargelimits=false, |
434
8664ff87cd77
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
433
diff
changeset
|
708 |
xtick={0,200,...,1100}, |
8664ff87cd77
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
433
diff
changeset
|
709 |
xmax=1200, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
710 |
ytick={0,5,...,30}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
711 |
scaled ticks=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
712 |
axis lines=left, |
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
713 |
width=8cm, |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
714 |
height=6.5cm, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
715 |
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
|
716 |
legend pos=outer north east, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
717 |
legend cell align=left |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
718 |
] |
434
8664ff87cd77
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
433
diff
changeset
|
719 |
\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
|
720 |
\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
|
721 |
\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
|
722 |
\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
|
723 |
\end{axis} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
724 |
\end{tikzpicture} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
725 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
726 |
|
335
2d112a7b29eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
727 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
728 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
729 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
730 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
731 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
732 |
\begin{frame}[c] |
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
733 |
\frametitle{Examples} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
734 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
735 |
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
|
736 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
737 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
738 |
\begin{tabular}{l} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
739 |
\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
|
740 |
\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
|
741 |
\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
|
742 |
\end{tabular} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
743 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
744 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
745 |
What are these regular expressions equivalent to? |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
746 |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
747 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
748 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
749 |
|
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
750 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
751 |
\begin{frame}[c] |
565 | 752 |
\frametitle{Simplification Rules} |
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
753 |
|
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
754 |
\begin{center} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
755 |
\bl{\begin{tabular}{rcl} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
756 |
$r + \ZERO$ & $\Rightarrow$ & $r$\\ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
757 |
$\ZERO + r$ & $\Rightarrow$ & $r$\\ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
758 |
$r \cdot \ONE$ & $\Rightarrow$ & $r$\\ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
759 |
$\ONE \cdot r$ & $\Rightarrow$ & $r$\\ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
760 |
$r \cdot \ZERO$ & $\Rightarrow$ & $\ZERO$\\ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
761 |
$\ZERO \cdot r$ & $\Rightarrow$ & $\ZERO$\\ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
762 |
$r + r$ & $\Rightarrow$ & $r$ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
763 |
\end{tabular}} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
764 |
\end{center} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
765 |
|
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
766 |
\footnotesize |
565 | 767 |
\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
|
768 |
\end{frame} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
769 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
770 |
|
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
771 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
772 |
\begin{frame}[c] |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
773 |
|
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
774 |
\footnotesize |
565 | 775 |
\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
|
776 |
|
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
777 |
\end{frame} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
778 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
779 |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
780 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
781 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
782 |
\begin{frame}[t] |
638 | 783 |
\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
|
784 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
785 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
786 |
\begin{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
787 |
\begin{axis}[ |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
788 |
xlabel={$n$}, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
789 |
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
|
790 |
ylabel={time in secs}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
791 |
enlargelimits=false, |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
792 |
xtick={0,5000,...,10000}, |
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
793 |
xmax=11000, |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
794 |
ymax=35, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
795 |
ytick={0,5,...,30}, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
796 |
scaled ticks=false, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
797 |
axis lines=left, |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
798 |
width=9cm, |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
799 |
height=7cm, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
800 |
legend entries={Scala V2,Scala V3}, |
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
801 |
legend pos=north east |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
802 |
] |
434
8664ff87cd77
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
433
diff
changeset
|
803 |
\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
|
804 |
\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
|
805 |
\end{axis} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
806 |
\end{tikzpicture} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
807 |
\end{center} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
808 |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
809 |
\end{frame} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
810 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
811 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
812 |
|
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
813 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
814 |
\begin{frame}[c] |
565 | 815 |
\frametitle{ |
638 | 816 |
Another Example\\[-2mm] |
817 |
in Java 8, Python and JavaScript} |
|
565 | 818 |
|
638 | 819 |
\bigskip |
565 | 820 |
\begin{center} |
821 |
\begin{tikzpicture} |
|
822 |
\begin{axis}[ |
|
823 |
xlabel={$n$}, |
|
824 |
x label style={at={(1.05,0.0)}}, |
|
825 |
ylabel={time in secs}, |
|
826 |
enlargelimits=false, |
|
827 |
xtick={0,5,...,30}, |
|
828 |
xmax=33, |
|
829 |
ymax=35, |
|
830 |
ytick={0,10,...,30}, |
|
831 |
scaled ticks=false, |
|
832 |
axis lines=left, |
|
833 |
width=9cm, |
|
638 | 834 |
height=5.5cm, |
835 |
legend entries={Java 8, Python, JavaScript}, |
|
565 | 836 |
legend pos=north west, |
837 |
legend cell align=left] |
|
838 |
\addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data}; |
|
839 |
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data}; |
|
638 | 840 |
\addplot[red,mark=*, mark options={fill=white}] table {re-js.data}; |
565 | 841 |
\end{axis} |
842 |
\end{tikzpicture} |
|
843 |
\end{center} |
|
844 |
||
845 |
Regex: \bl{$(a^*)^* \cdot b$} |
|
846 |
||
847 |
Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$} |
|
848 |
||
849 |
\end{frame} |
|
850 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
851 |
||
852 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
853 |
\begin{frame}[c] |
|
638 | 854 |
\frametitle{Same Example in Java 9+} |
565 | 855 |
|
856 |
\begin{center} |
|
857 |
\begin{tikzpicture} |
|
858 |
\begin{axis}[ |
|
859 |
xlabel={$n$}, |
|
860 |
x label style={at={(1.09,-0.15)}}, |
|
861 |
ylabel={time in secs}, |
|
862 |
scaled x ticks=false, |
|
863 |
enlargelimits=false, |
|
864 |
xtick distance=10000, |
|
865 |
xmax=44000, |
|
866 |
ytick={0,10,...,30}, |
|
867 |
ymax=35, |
|
868 |
axis lines=left, |
|
869 |
width=9cm, |
|
870 |
height=5cm, |
|
871 |
legend entries={Java \liningnums{9}+}, |
|
872 |
legend pos=north west, |
|
873 |
legend cell align=left] |
|
874 |
\addplot[blue,mark=square*,mark options={fill=white}] table {re-java9.data}; |
|
875 |
\end{axis} |
|
876 |
\end{tikzpicture} |
|
877 |
\end{center} |
|
878 |
||
879 |
Regex: \bl{$(a^*)^* \cdot b$} |
|
880 |
||
881 |
Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$} |
|
882 |
||
883 |
\end{frame} |
|
884 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
885 |
||
886 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
887 |
\begin{frame}[c] |
|
646 | 888 |
\frametitle{\ldots{}and with Brzozowski} |
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
889 |
|
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
890 |
\begin{center} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
891 |
\begin{tikzpicture} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
892 |
\begin{axis}[ |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
893 |
xlabel={$n$}, |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
894 |
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
|
895 |
ylabel={time in secs}, |
565 | 896 |
scaled x ticks=false, |
897 |
xtick distance=2000000, |
|
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
898 |
enlargelimits=false, |
565 | 899 |
xmax=6400000, |
514 | 900 |
ytick={0,10,...,30}, |
901 |
ymax=35, |
|
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
902 |
axis lines=left, |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
903 |
width=9cm, |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
904 |
height=5cm, |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
905 |
legend entries={Scala V3}, |
565 | 906 |
legend pos=north west, |
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
907 |
legend cell align=left] |
514 | 908 |
%\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
|
909 |
\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
|
910 |
\end{axis} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
911 |
\end{tikzpicture} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
912 |
\end{center} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
913 |
|
565 | 914 |
Regex: \bl{$(a^*)^* \cdot b$} |
915 |
||
916 |
Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$} |
|
917 |
||
435
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
918 |
\end{frame} |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
919 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
e08431a78f66
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
434
diff
changeset
|
920 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
921 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
573 | 922 |
\begin{frame}[c] |
923 |
\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
|
924 |
|
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
925 |
\begin{itemize} |
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
926 |
\item extends to most regular expressions, for example |
573 | 927 |
\bl{$\sim r$} (next slide) |
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
928 |
|
573 | 929 |
\item is easy to implement in a functional language (slide after) |
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
930 |
|
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
931 |
\item the algorithm is already quite old; there is still |
514 | 932 |
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
|
933 |
|
638 | 934 |
\item we can prove its correctness\ldots (several slides later) |
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
935 |
\end{itemize} |
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
936 |
|
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
937 |
\end{frame} |
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
938 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
939 |
|
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
940 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
566 | 941 |
\begin{frame}[c] |
942 |
\frametitle{Negation of Regular Expr's} |
|
943 |
||
944 |
\begin{itemize} |
|
945 |
\item \bl{$\sim{}r$} \hspace{6mm} (everything that \bl{$r$} cannot recognise)\medskip |
|
946 |
\item \bl{$L(\sim{}r) \dn UNIV - L(r)$}\medskip |
|
947 |
\item \bl{$nullable (\sim{}r) \dn not\, (nullable(r))$}\medskip |
|
948 |
\item \bl{$der\,c\,(\sim{}r) \dn \;\sim{}(der\,c\,r)$} |
|
949 |
\end{itemize}\bigskip\pause |
|
950 |
||
951 |
Used often for recognising comments: |
|
952 |
||
953 |
\[ |
|
954 |
\bl{/ \cdot * \cdot (\sim{}([a\mbox{-}z]^* \cdot * \cdot / \cdot [a\mbox{-}z]^*)) \cdot * \cdot /} |
|
955 |
\] |
|
956 |
||
957 |
\end{frame} |
|
958 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
959 |
||
960 |
||
961 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
962 |
\begin{frame}[c] |
|
963 |
\frametitle{Coursework} |
|
964 |
||
965 |
\underline{Strand 1:} |
|
966 |
||
967 |
\begin{itemize} |
|
638 | 968 |
\item Submission on Friday 11 October\\accepted until Monday 14 @ 18:00\medskip |
566 | 969 |
\item source code needs to be submitted as well\medskip |
970 |
\item you can re-use my Scala code from KEATS \\ |
|
971 |
or use any programming language you like\medskip |
|
972 |
\item \small https://nms.kcl.ac.uk/christian.urban/ProgInScala2ed.pdf\normalsize |
|
973 |
\end{itemize} |
|
974 |
||
975 |
\end{frame} |
|
976 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
977 |
||
978 |
||
979 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
342
c235e0aeb8df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
338
diff
changeset
|
980 |
\begin{frame}[t] |
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
981 |
\frametitle{Proofs about Rexps} |
17 | 982 |
|
983 |
Remember their inductive definition:\\[5cm] |
|
984 |
||
985 |
\begin{textblock}{6}(5,5) |
|
986 |
\begin{tabular}{@ {}rrl} |
|
429
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
987 |
\bl{$r$} & \bl{$::=$} & \bl{$\ZERO$}\\ |
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
988 |
& \bl{$\mid$} & \bl{$\ONE$} \\ |
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
989 |
& \bl{$\mid$} & \bl{$c$} \\ |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
990 |
& \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
|
991 |
& \bl{$\mid$} & \bl{$r_1 + r_2$} \\ |
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
992 |
& \bl{$\mid$} & \bl{$r^*$} \\ |
17 | 993 |
\end{tabular} |
994 |
\end{textblock} |
|
995 |
||
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
996 |
If we want to prove something, say a property \bl{$P(r)$}, for all regular expressions \bl{$r$} then \ldots |
17 | 997 |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
998 |
\end{frame} |
17 | 999 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1000 |
||
1001 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1002 |
\begin{frame}[c] |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1003 |
\frametitle{Proofs about Rexp (2)} |
17 | 1004 |
|
1005 |
\begin{itemize} |
|
429
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
1006 |
\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
|
1007 |
\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
|
1008 |
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
|
1009 |
\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
|
1010 |
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
|
1011 |
\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
|
1012 |
holds for \bl{$r$}. |
17 | 1013 |
\end{itemize} |
1014 |
||
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1015 |
\end{frame} |
17 | 1016 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1017 |
||
1018 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1019 |
\begin{frame}[c] |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1020 |
\frametitle{Proofs about Rexp (3)} |
17 | 1021 |
|
1022 |
Assume \bl{$P(r)$} is the property: |
|
1023 |
||
1024 |
\begin{center} |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1025 |
\bl{$nullable(r)$} if and only if \bl{$[] \in L(r)$} |
17 | 1026 |
\end{center} |
1027 |
||
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1028 |
\end{frame} |
17 | 1029 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1030 |
||
1031 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1032 |
\begin{frame}[c] |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1033 |
\frametitle{Proofs about Rexp (4)} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1034 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1035 |
\begin{center} |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1036 |
\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
|
1037 |
$rev(\ZERO)$ & $\dn$ & $\ZERO$\\ |
7e71c947ec69
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
398
diff
changeset
|
1038 |
$rev(\ONE)$ & $\dn$ & $\ONE$\\ |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1039 |
$rev(c)$ & $\dn$ & $c$\\ |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1040 |
$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
|
1041 |
$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
|
1042 |
$rev(r^*)$ & $\dn$ & $rev(r)^*$\\ |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1043 |
\end{tabular}} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1044 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1045 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1046 |
We can prove |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1047 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1048 |
\begin{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1049 |
\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
|
1050 |
\end{center} |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1051 |
|
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1052 |
by induction on \bl{$r$}. |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1053 |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1054 |
\end{frame} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1055 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1056 |
|
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1057 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1058 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1059 |
\begin{frame}[c] |
638 | 1060 |
\frametitle{Correctness Proof \\[-1mm] |
1061 |
for our Matcher} |
|
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1062 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1063 |
\begin{itemize} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1064 |
\item We started from |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1065 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1066 |
\begin{center} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1067 |
\begin{tabular}{rp{4cm}} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1068 |
& \bl{$s \in L(r)$}\medskip\\ |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1069 |
\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
|
1070 |
\end{tabular} |
638 | 1071 |
\end{center}\bigskip |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1072 |
|
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1073 |
\item if we can show \bl{$\Ders\, s\,(L(r)) = L(\ders\,s\,r)$} we |
638 | 1074 |
have\bigskip |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1075 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1076 |
\begin{center} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1077 |
\begin{tabular}{rp{4cm}} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1078 |
\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
|
1079 |
\bl{$\Leftrightarrow$} & \bl{$nullable(\ders\,s\,r)$}\medskip\\ |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1080 |
\bl{$\dn$} & \bl{$matches\,s\,r$} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1081 |
\end{tabular} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1082 |
\end{center} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1083 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1084 |
\end{itemize} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1085 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1086 |
\end{frame} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1087 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1088 |
|
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1089 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1090 |
\begin{frame}[c] |
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1091 |
\frametitle{Proofs about Rexp (5)} |
263
92e6985018ae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
261
diff
changeset
|
1092 |
|
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1093 |
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
|
1094 |
|
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1095 |
\begin{center} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1096 |
\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
|
1097 |
\end{center} |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1098 |
|
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1099 |
We can prove |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1100 |
|
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1101 |
\begin{center} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1102 |
\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
|
1103 |
\end{center} |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1104 |
|
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1105 |
by induction on \bl{$r$}. |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1106 |
|
337
885ac2b6c27d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
1107 |
\end{frame} |
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1108 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1109 |
|
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1110 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1111 |
\begin{frame}[c] |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1112 |
\frametitle{Proofs about Strings} |
17 | 1113 |
|
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1114 |
If we want to prove something, say a property \bl{$P(s)$}, for all strings \bl{$s$} then \ldots\bigskip |
17 | 1115 |
|
1116 |
\begin{itemize} |
|
1117 |
\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
|
1118 |
\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
|
1119 |
already holds for \bl{$s$} |
17 | 1120 |
\end{itemize} |
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1121 |
\end{frame} |
17 | 1122 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1123 |
||
19 | 1124 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1125 |
\begin{frame}[c] |
|
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1126 |
\frametitle{Proofs about Strings (2)} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1127 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1128 |
We can then prove |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1129 |
|
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1130 |
\begin{center} |
433
c08290ee4f1f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
1131 |
\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
|
1132 |
\end{center} |
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1133 |
|
19 | 1134 |
|
119
a6684e8961d0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
118
diff
changeset
|
1135 |
We can finally prove |
19 | 1136 |
|
1137 |
\begin{center} |
|
345
0922b3e01289
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
342
diff
changeset
|
1138 |
\bl{$matches\,s\,r$} if and only if \bl{$s \in L(r)$} |
19 | 1139 |
\end{center} |
1140 |
||
1141 |
||
338
f16120cb4e19
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
337
diff
changeset
|
1142 |
\end{frame} |
19 | 1143 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
17 | 1144 |
|
436
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1145 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1146 |
\begin{frame}[c] |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1147 |
\frametitle{Epilogue} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1148 |
|
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1149 |
\footnotesize |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1150 |
\begin{center} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1151 |
\begin{tabular}{cc} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1152 |
\begin{tikzpicture} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1153 |
\begin{axis}[ |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
1154 |
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
|
1155 |
xlabel={$n$}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1156 |
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
|
1157 |
ylabel={time in secs}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1158 |
enlargelimits=false, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1159 |
xmax=7100000, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1160 |
ytick={0,5,...,30}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1161 |
ymax=33, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1162 |
%scaled ticks=false, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1163 |
axis lines=left, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1164 |
width=5cm, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1165 |
height=5cm, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1166 |
legend entries={Scala V3, Scala V4}, |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
1167 |
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
|
1168 |
\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
|
1169 |
\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
|
1170 |
\end{axis} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1171 |
\end{tikzpicture} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1172 |
& |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1173 |
\begin{tikzpicture} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1174 |
\begin{axis}[ |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
1175 |
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
|
1176 |
xlabel={$n$}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1177 |
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
|
1178 |
ylabel={time in secs}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1179 |
enlargelimits=false, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1180 |
xmax=8100000, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1181 |
ytick={0,5,...,30}, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1182 |
ymax=33, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1183 |
%scaled ticks=false, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1184 |
axis lines=left, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1185 |
width=5cm, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1186 |
height=5cm, |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1187 |
legend entries={Scala V3, Scala V4}, |
442
84d6714840c9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
436
diff
changeset
|
1188 |
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
|
1189 |
\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
|
1190 |
\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
|
1191 |
\end{axis} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1192 |
\end{tikzpicture} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1193 |
\end{tabular} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1194 |
\end{center} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1195 |
|
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1196 |
\only<2->{\footnotesize |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1197 |
\begin{textblock}{9}(0.5,8) |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1198 |
\begin{bubble}[11.8cm] |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1199 |
\lstinputlisting[numbers=none]{../progs/app52.scala} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1200 |
\end{bubble} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1201 |
\end{textblock}} |
510 | 1202 |
|
436
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1203 |
|
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1204 |
\end{frame} |
9213b8298ca9
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
435
diff
changeset
|
1205 |
|
638 | 1206 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1207 |
\begin{frame}[c] |
|
1208 |
\frametitle{Another Homework Question} |
|
1209 |
||
1210 |
\begin{itemize} |
|
1211 |
\item How many basic regular expressions are there to match |
|
1212 |
the string \bl{$abcd$}\,?\pause |
|
1213 |
\item How many if they cannot include |
|
1214 |
\bl{$\ONE$} and \bl{$\ZERO$}\/?\pause |
|
1215 |
\item How many if they are also not |
|
1216 |
allowed to contain stars?\pause |
|
1217 |
\item How many if they are also |
|
1218 |
not allowed to contain \bl{$\_ + \_$}\/? |
|
1219 |
\end{itemize} |
|
1220 |
||
1221 |
\end{frame} |
|
1222 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1223 |
||
1224 |
||
7 | 1225 |
\end{document} |
1226 |
||
1227 |
%%% Local Variables: |
|
1228 |
%%% mode: latex |
|
1229 |
%%% TeX-master: t |
|
1230 |
%%% End: |
|
1231 |