45 for,if,implicit,import,match,mixin,% |
51 for,if,implicit,import,match,mixin,% |
46 new,null,object,override,package,% |
52 new,null,object,override,package,% |
47 private,protected,requires,return,sealed,% |
53 private,protected,requires,return,sealed,% |
48 super,this,throw,trait,true,try,% |
54 super,this,throw,trait,true,try,% |
49 type,val,var,while,with,yield}, |
55 type,val,var,while,with,yield}, |
50 otherkeywords={=>,<-,<\%,<:,>:,\#,@}, |
56 otherkeywords={=>,<-,<\%,<:,>:,\#,@,->}, |
51 sensitive=true, |
57 sensitive=true, |
52 morecomment=[l]{//}, |
58 morecomment=[l]{//}, |
53 morecomment=[n]{/*}{*/}, |
59 morecomment=[n]{/*}{*/}, |
54 morestring=[b]", |
60 morestring=[b]", |
55 morestring=[b]', |
61 morestring=[b]', |
56 morestring=[b]""" |
62 morestring=[b]""" |
57 } |
63 } |
58 |
64 |
59 \lstset{language=Scala, |
65 \lstset{language=Scala, |
60 basicstyle=\ttfamily, |
66 basicstyle=\consolas, |
61 keywordstyle=\color{javapurple}\bfseries, |
67 keywordstyle=\color{javapurple}\bfseries, |
62 stringstyle=\color{javagreen}, |
68 stringstyle=\color{javagreen}, |
63 commentstyle=\color{javagreen}, |
69 commentstyle=\color{javagreen}, |
64 morecomment=[s][\color{javadocblue}]{/**}{*/}, |
70 morecomment=[s][\color{javadocblue}]{/**}{*/}, |
65 numbers=left, |
71 numbers=left, |
111 \begin{frame}[c] |
171 \begin{frame}[c] |
112 \frametitle{\begin{tabular}{c}Languages\end{tabular}} |
172 \frametitle{\begin{tabular}{c}Languages\end{tabular}} |
113 |
173 |
114 A \alert{language} is a set of strings.\bigskip |
174 A \alert{language} is a set of strings.\bigskip |
115 |
175 |
116 A \alert{regular expression} specifies a set of strings or language. |
176 A \alert{regular expression} specifies a set of strings, or language. |
117 |
177 |
118 \end{frame}} |
178 \end{frame}} |
119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
180 |
|
181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
182 \mode<presentation>{ |
|
183 \begin{frame}[t] |
|
184 \frametitle{\begin{tabular}{c}Strings\end{tabular}} |
|
185 |
|
186 Different ways of writing strings: |
|
187 |
|
188 \begin{center} |
|
189 \begin{tabular}{ccc} |
|
190 \bl{\consolas"$hello$"}\quad{} & \bl{$[h, e, l, l, o]$} & \quad\bl{$h\!::\!e\!::\!l\!::\!l\!::\!o\!::\!N\!il$}\bigskip\\ |
|
191 \bl{\consolas ""} & \bl{$[]$} & \bl{$N$\!$il$} |
|
192 \end{tabular} |
|
193 \end{center}\pause |
|
194 |
|
195 The concatenation operation on strings and sets of strings: |
|
196 |
|
197 \begin{center} |
|
198 \begin{tabular}{l} |
|
199 \bl{{\consolas"$f\!oo$"}$\;@\;${\consolas"$bar$"}$\;=\;${\consolas"$f\!oobar$"}}\medskip\\ |
|
200 \bl{$A \;@\; B \dn \{ s_1 @ s_2 \mid s_1 \in A \wedge s_2 \in B\}$} |
|
201 \end{tabular} |
|
202 \end{center} |
|
203 |
|
204 \end{frame}} |
|
205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
206 |
|
207 |
120 |
208 |
121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
122 \mode<presentation>{ |
210 \mode<presentation>{ |
123 \begin{frame}[t] |
211 \begin{frame}[t] |
124 \frametitle{\begin{tabular}{c}Regular Expressions\end{tabular}} |
212 \frametitle{\begin{tabular}{c}Regular Expressions\end{tabular}} |
125 |
213 |
126 Their inductive definition: |
214 Their inductive definition: |
127 |
215 |
128 |
216 |
129 \begin{textblock}{6}(2,5) |
217 \begin{textblock}{6}(2,6.5) |
130 \begin{tabular}{@ {}rrl@ {\hspace{13mm}}l} |
218 \begin{tabular}{@ {}rrl@ {\hspace{13mm}}l} |
131 \bl{r} & \bl{$::=$} & \bl{$\varnothing$} & null\\ |
219 \bl{r} & \bl{$::=$} & \bl{$\varnothing$} & null\\ |
132 & \bl{$\mid$} & \bl{$\epsilon$} & empty string / "" / []\\ |
220 & \bl{$\mid$} & \bl{$\epsilon$} & empty string / {\consolas""} / $[]$\\ |
133 & \bl{$\mid$} & \bl{c} & character\\ |
221 & \bl{$\mid$} & \bl{c} & character\\ |
134 & \bl{$\mid$} & \bl{r$_1$ $\cdot$ r$_2$} & sequence\\ |
222 & \bl{$\mid$} & \bl{r$_1$ $\cdot$ r$_2$} & sequence\\ |
135 & \bl{$\mid$} & \bl{r$_1$ + r$_2$} & alternative / choice\\ |
223 & \bl{$\mid$} & \bl{r$_1$ + r$_2$} & alternative / choice\\ |
136 & \bl{$\mid$} & \bl{r$^*$} & star (zero or more)\\ |
224 & \bl{$\mid$} & \bl{r$^*$} & star (zero or more)\\ |
137 \end{tabular} |
225 \end{tabular} |
138 \end{textblock} |
226 \end{textblock} |
139 |
227 |
140 \end{frame}} |
228 |
141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
229 \only<2->{ |
142 |
230 \begin{textblock}{9}(4,0.5) |
143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
231 \begin{tikzpicture} |
144 \mode<presentation>{ |
232 \draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
145 \begin{frame}[t] |
233 {\normalsize\color{darkgray} |
146 \frametitle{\begin{tabular}{c}Regular Expressions\end{tabular}} |
234 \begin{minipage}{9cm} |
147 |
235 \hspace{5mm}\mbox{{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
148 Their implementation in Scala: |
236 \texttt{\lstinputlisting{../progs/app51.scala}}}} |
149 |
237 \end{minipage}}; |
150 {\lstset{language=Scala}\fontsize{8}{10}\selectfont |
238 \end{tikzpicture} |
151 \texttt{\lstinputlisting{app51.scala}}} |
239 \end{textblock}} |
152 |
240 |
153 |
241 \end{frame}} |
154 \end{frame}} |
242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
156 |
|
157 |
243 |
158 |
244 |
159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
160 \mode<presentation>{ |
246 \mode<presentation>{ |
161 \begin{frame}[c] |
247 \begin{frame}[c] |
162 \frametitle{\begin{tabular}{c}The Meaning of a\\[-2mm] Regular Expression\end{tabular}} |
248 \frametitle{\begin{tabular}{c}The Meaning of a\\[-2mm] Regular Expression\end{tabular}} |
163 |
249 |
164 \begin{textblock}{15}(1,4) |
250 \begin{textblock}{15}(1,4) |
165 \begin{tabular}{@ {}rcl} |
251 \begin{tabular}{@ {}rcl} |
166 \bl{$L$($\varnothing$)} & \bl{$\dn$} & \bl{$\varnothing$}\\ |
252 \bl{$L(\varnothing)$} & \bl{$\dn$} & \bl{$\varnothing$}\\ |
167 \bl{$L$($\epsilon$)} & \bl{$\dn$} & \bl{$\{$""$\}$}\\ |
253 \bl{$L(\epsilon)$} & \bl{$\dn$} & \bl{$\{$""$\}$}\\ |
168 \bl{$L$(c)} & \bl{$\dn$} & \bl{$\{$"c"$\}$}\\ |
254 \bl{$L(c)$} & \bl{$\dn$} & \bl{$\{"c"\}$}\\ |
169 \bl{$L$(r$_1$ + r$_2$)} & \bl{$\dn$} & \bl{$L$(r$_1$) $\cup$ $L$(r$_2$)}\\ |
255 \bl{$L(r_1 + r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\ |
170 \bl{$L$(r$_1$ $\cdot$ r$_2$)} & \bl{$\dn$} & \bl{$L$(r$_1$) @ $L$(r$_2$)}\\ |
256 \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \,@\, L(r_2)$}\\ |
171 \bl{$L$(r$^*$)} & \bl{$\dn$} & \bl{$\bigcup_{n \ge 0}$ $L$(r)$^n$}\\ |
257 \bl{$L(r^*)$} & \bl{$\dn$} & \bl{$\bigcup_{n \ge 0} L(r)^n$}\\ |
172 \end{tabular}\bigskip |
258 \end{tabular}\bigskip |
173 |
259 |
174 \hspace{5mm}\textcolor{gray}{$L$(r)$^0$ $\;\dn\;$ $\{$""$\}$}\\ |
260 \only<2->{ |
175 \textcolor{gray}{$L$(r)$^{n+1}$ $\;\dn\;$ $L$(r) @ $L$(r)$^n$} |
261 \hspace{5mm}\textcolor{blue}{$L(r)^0 \;\dn\; \{""\}$}\\ |
|
262 \textcolor{blue}{$L(r)^{n+1} \;\dn\; L(r) \,@\, L(r)^n$}} |
176 \end{textblock} |
263 \end{textblock} |
177 |
264 |
178 \only<2->{ |
265 |
179 \begin{textblock}{5}(11,5) |
266 |
180 \textcolor{gray}{\small |
267 \only<1->{ |
181 A @ B\\ |
|
182 \ldots you take out every string from A and |
|
183 concatenate it with every string in B |
|
184 } |
|
185 \end{textblock}} |
|
186 |
|
187 \only<3->{ |
|
188 \begin{textblock}{6}(9,12)\small |
268 \begin{textblock}{6}(9,12)\small |
189 \bl{$L$} is a function from regular expressions to sets of strings\\ |
269 \bl{$L$} is a function from regular expressions to sets of strings\\ |
190 \bl{$L$ : Rexp $\Rightarrow$ Set[String]} |
270 \bl{$L$ : Rexp $\Rightarrow$ Set$[$String$]$} |
191 \end{textblock}} |
271 \end{textblock}} |
192 |
272 |
193 |
273 |
194 \end{frame}} |
274 \end{frame}} |
195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
275 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
216 \begin{frame}[c] |
296 \begin{frame}[c] |
217 \frametitle{\begin{tabular}{c}Reg Exp Equivalences\end{tabular}} |
297 \frametitle{\begin{tabular}{c}Reg Exp Equivalences\end{tabular}} |
218 |
298 |
219 \begin{center} |
299 \begin{center} |
220 \begin{tabular}{l@ {\hspace{7mm}}rcl@ {\hspace{7mm}}l} |
300 \begin{tabular}{l@ {\hspace{7mm}}rcl@ {\hspace{7mm}}l} |
221 &\bl{(a + b) + c} & \bl{$\equiv^?$} & \bl{a + (b + c)} & \onslide<2->{\YES}\\ |
301 &\bl{$(a + b) + c$} & \bl{$\equiv^?$} & \bl{$a + (b + c)$} & \onslide<2->{\YES}\\ |
222 &\bl{a + a} & \bl{$\equiv^?$} & \bl{a} & \onslide<3->{\YES}\\ |
302 &\bl{$a + a$} & \bl{$\equiv^?$} & \bl{$a$} & \onslide<3->{\YES}\\ |
223 &\bl{(a $\cdot$ b) $\cdot$ c} & \bl{$\equiv^?$} & \bl{a $\cdot$ (b $\cdot$ c)} & \onslide<4->{\YES}\\ |
303 &\bl{$(a \cdot b) \cdot c$} & \bl{$\equiv^?$} & \bl{$a \cdot (b \cdot c)$} & \onslide<4->{\YES}\\ |
224 &\bl{a $\cdot$ a} & \bl{$\equiv^?$} & \bl{a} & \onslide<5->{\NO}\\ |
304 &\bl{$a \cdot a$} & \bl{$\equiv^?$} & \bl{$a$} & \onslide<5->{\NO}\\ |
225 &\bl{$\epsilon^*$} & \bl{$\equiv^?$} & \bl{$\epsilon$} & \onslide<6->{\YES}\\ |
305 &\bl{$\epsilon^*$} & \bl{$\equiv^?$} & \bl{$\epsilon$} & \onslide<6->{\YES}\\ |
226 &\bl{$\varnothing^*$} & \bl{$\equiv^?$} & \bl{$\varnothing$} & \onslide<7->{\NO}\\ |
306 &\bl{$\varnothing^*$} & \bl{$\equiv^?$} & \bl{$\varnothing$} & \onslide<7->{\NO}\\ |
227 \FORALLR &\bl{r $\cdot$ $\epsilon$} & \bl{$\equiv^?$} & \bl{r} & \onslide<8->{\YES}\\ |
307 \FORALLR &\bl{$r \cdot \epsilon$} & \bl{$\equiv^?$} & \bl{$r$} & \onslide<8->{\YES}\\ |
228 \FORALLR &\bl{r + $\epsilon$} & \bl{$\equiv^?$} & \bl{r} & \onslide<9->{\NO}\\ |
308 \FORALLR &\bl{$r + \epsilon$} & \bl{$\equiv^?$} & \bl{$r$} & \onslide<9->{\NO}\\ |
229 \FORALLR &\bl{r + $\varnothing$} & \bl{$\equiv^?$} & \bl{r} & \onslide<10->{\YES}\\ |
309 \FORALLR &\bl{$r + \varnothing$} & \bl{$\equiv^?$} & \bl{$r$} & \onslide<10->{\YES}\\ |
230 \FORALLR &\bl{r $\cdot$ $\varnothing$} & \bl{$\equiv^?$} & \bl{r} & \onslide<11->{\NO}\\ |
310 \FORALLR &\bl{$r \cdot \varnothing$} & \bl{$\equiv^?$} & \bl{$r$} & \onslide<11->{\NO}\\ |
231 &\bl{c $\cdot$ (a + b)} & \bl{$\equiv^?$} & \bl{(c $\cdot$ a) + (c $\cdot$ b)} & \onslide<12->{\YES}\\ |
311 &\bl{$c \cdot (a + b)$} & \bl{$\equiv^?$} & \bl{$(c \cdot a) + (c \cdot b)$} & \onslide<12->{\YES}\\ |
232 &\bl{a$^*$} & \bl{$\equiv^?$} & \bl{$\epsilon$ + (a $\cdot$ a$^*$)} & \onslide<13->{\YES} |
312 &\bl{$a^*$} & \bl{$\equiv^?$} & \bl{$\epsilon + (a \cdot a^*)$} & \onslide<13->{\YES} |
233 \end{tabular} |
313 \end{tabular} |
234 \end{center} |
314 \end{center} |
235 |
315 |
236 \end{frame}} |
316 \end{frame}} |
237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
317 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
238 |
318 |
239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
319 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
240 \mode<presentation>{ |
320 \mode<presentation>{ |
241 \begin{frame}[c] |
321 \begin{frame}[c] |
242 \frametitle{\begin{tabular}{c}The Meaning of Matching\end{tabular}} |
322 \frametitle{\begin{tabular}{c}The Specification\\[-1mm] of Matching\end{tabular}} |
243 |
323 |
244 \large |
324 \large |
245 a regular expression \bl{r} matches a string \bl{s} is defined as |
325 a regular expression \bl{r} matches a string \bl{s} is defined as |
246 |
326 |
247 \begin{center} |
327 \begin{center} |
248 \bl{s $\in$ $L$(r)}\\ |
328 \bl{s $\in$ $L$(r)}\\ |
249 \end{center}\bigskip\bigskip\pause |
329 \end{center}\bigskip\bigskip\pause |
250 |
330 |
251 \small |
331 \end{frame}} |
252 if \bl{r$_1$ $\equiv$ r$_2$}, then \bl{$s$ $\in$ $L$(r$_1$)} iff \bl{$s$ $\in$ $L$(r$_2$)} |
332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
333 |
|
334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
335 \mode<presentation>{ |
|
336 \begin{frame}[t] |
|
337 \frametitle{\begin{tabular}{c}\bl{$(a?\{n\}) \cdot a\{n\}$}\end{tabular}} |
|
338 |
|
339 \mbox{}\\[-13mm] |
|
340 |
|
341 \begin{tikzpicture}[y=.2cm, x=.3cm] |
|
342 %axis |
|
343 \draw (0,0) -- coordinate (x axis mid) (30,0); |
|
344 \draw (0,0) -- coordinate (y axis mid) (0,30); |
|
345 %ticks |
|
346 \foreach \x in {0,5,...,30} |
|
347 \draw (\x,1pt) -- (\x,-3pt) |
|
348 node[anchor=north] {\x}; |
|
349 \foreach \y in {0,5,...,30} |
|
350 \draw (1pt,\y) -- (-3pt,\y) |
|
351 node[anchor=east] {\y}; |
|
352 %labels |
|
353 \node[below=0.6cm] at (x axis mid) {\bl{a}s}; |
|
354 \node[rotate=90, left=1.2cm] at (y axis mid) {secs}; |
|
355 |
|
356 %plots |
|
357 \draw[color=blue] plot[mark=*, mark options={fill=white}] |
|
358 file {re-python.data}; |
|
359 \draw[color=red] plot[mark=triangle*, mark options={fill=white} ] |
|
360 file {re1.data}; |
|
361 \draw[color=green] plot[mark=square*, mark options={fill=white} ] |
|
362 file {re2.data}; |
|
363 \draw[color=brown] plot[mark=pentagon*, mark options={fill=white} ] |
|
364 file {re-ruby.data}; |
|
365 |
|
366 %legend |
|
367 \begin{scope}[shift={(4,20)}] |
|
368 \draw[color=blue] (0,0) -- |
|
369 plot[mark=*, mark options={fill=white}] (0.25,0) -- (0.5,0) |
|
370 node[right]{\small Python}; |
|
371 \draw[yshift=-\baselineskip, color=brown] (0,0) -- |
|
372 plot[mark=pentagon*, mark options={fill=white}] (0.25,0) -- (0.5,0) |
|
373 node[right]{\small Ruby}; |
|
374 \end{scope} |
|
375 \end{tikzpicture} |
253 |
376 |
254 \end{frame}} |
377 \end{frame}} |
255 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
256 |
379 |
257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
380 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
258 \mode<presentation>{ |
381 \mode<presentation>{ |
259 \begin{frame}[t] |
382 \begin{frame}[t] |
260 \frametitle{\begin{tabular}{c}A Matching Algorithm\end{tabular}} |
383 \frametitle{\begin{tabular}{c}A Matching Algorithm\end{tabular}} |
261 |
384 |
262 \begin{itemize} |
385 \small |
263 \item given a regular expression \bl{r} and a string \bl{s}, say yes or no for whether |
386 \ldots{}whether a regular expression can match the empty string: |
264 \begin{center} |
387 \begin{center} |
265 \bl{s $\in$ $L$(r)} |
388 \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
|
389 \bl{$nullable(\varnothing)$} & \bl{$\dn$} & \bl{$f\!\/alse$}\\ |
|
390 \bl{$nullable(\epsilon)$} & \bl{$\dn$} & \bl{$true$}\\ |
|
391 \bl{$nullable (c)$} & \bl{$\dn$} & \bl{$f\!alse$}\\ |
|
392 \bl{$nullable (r_1 + r_2)$} & \bl{$\dn$} & \bl{$nullable(r_1) \vee nullable(r_2)$} \\ |
|
393 \bl{$nullable (r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$nullable(r_1) \wedge nullable(r_2)$} \\ |
|
394 \bl{$nullable (r^*)$} & \bl{$\dn$} & \bl{$true$} \\ |
|
395 \end{tabular} |
266 \end{center} |
396 \end{center} |
267 or not.\bigskip\bigskip\pause |
397 |
268 \end{itemize}\pause |
398 \only<2->{ |
269 |
399 \begin{textblock}{9}(3.4,10) |
270 \small |
400 \begin{tikzpicture} |
271 \begin{itemize} |
401 \draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
272 \item Identifiers (strings of letters or digits, starting with a letter) |
402 {\normalsize\color{darkgray} |
273 \item Integers (a non-empty sequence of digits) |
403 \begin{minipage}{9cm} |
274 \item Keywords (else, if, while, \ldots) |
404 \hspace{5mm}\mbox{{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
275 \item White space (a non-empty sequence of blanks, newlines and tabs) |
405 \texttt{\lstinputlisting{../progs/app5.scala}}}} |
276 \end{itemize} |
406 \end{minipage}}; |
277 \end{frame}} |
407 \end{tikzpicture} |
278 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
408 \end{textblock}} |
279 |
409 |
280 |
410 \end{frame}} |
281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
411 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
282 \mode<presentation>{ |
412 |
283 \begin{frame}[c] |
|
284 \frametitle{\begin{tabular}{c}A Matching Algorithm\end{tabular}} |
|
285 |
|
286 \small |
|
287 whether a regular expression matches the empty string:\medskip |
|
288 |
|
289 |
|
290 {\lstset{language=Scala}\fontsize{8}{10}\selectfont |
|
291 \texttt{\lstinputlisting{app5.scala}}} |
|
292 |
|
293 |
|
294 |
|
295 \end{frame}} |
|
296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
297 |
413 |
298 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
414 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
299 \mode<presentation>{ |
415 \mode<presentation>{ |
300 \begin{frame}[c] |
416 \begin{frame}[c] |
301 \frametitle{\begin{tabular}{c}The Derivative of a Rexp\end{tabular}} |
417 \frametitle{\begin{tabular}{c}The Derivative of a Rexp\end{tabular}} |
302 |
418 |
303 \large |
419 \large |
304 If \bl{r} matches the string \bl{c::s}, what is a regular expression that matches \bl{s}?\bigskip\bigskip\bigskip\bigskip |
420 If \bl{r} matches the string \bl{c::s}, what is a regular expression that matches \bl{s}?\bigskip\bigskip\bigskip\bigskip |
305 |
421 |
306 \small |
422 \small |
307 \bl{der c r} gives the answer |
423 \bl{$der\,c\,r$} gives the answer |
308 \end{frame}} |
424 \end{frame}} |
309 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
310 |
426 |
311 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
427 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
312 \mode<presentation>{ |
428 \mode<presentation>{ |
313 \begin{frame}[c] |
429 \begin{frame}[c] |
314 \frametitle{\begin{tabular}{c}The Derivative of a Rexp (2)\end{tabular}} |
430 \frametitle{\begin{tabular}{c}The Derivative of a Rexp (2)\end{tabular}} |
315 |
431 |
316 \begin{center} |
432 \begin{center} |
317 \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {\hspace{-10mm}}l@ {}} |
433 \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {\hspace{-10mm}}l@ {}} |
318 \bl{der c ($\varnothing$)} & \bl{$\dn$} & \bl{$\varnothing$} & \\ |
434 \bl{$der\, c\, (\varnothing)$} & \bl{$\dn$} & \bl{$\varnothing$} & \\ |
319 \bl{der c ($\epsilon$)} & \bl{$\dn$} & \bl{$\varnothing$} & \\ |
435 \bl{$der\, c\, (\epsilon)$} & \bl{$\dn$} & \bl{$\varnothing$} & \\ |
320 \bl{der c (d)} & \bl{$\dn$} & \bl{if c $=$ d then $\epsilon$ else $\varnothing$} & \\ |
436 \bl{$der\, c\, (d)$} & \bl{$\dn$} & \bl{if $c = d$ then $\epsilon$ else $\varnothing$} & \\ |
321 \bl{der c (r$_1$ + r$_2$)} & \bl{$\dn$} & \bl{(der c r$_1$) + (der c r$_2$)} & \\ |
437 \bl{$der\, c\, (r_1 + r_2)$} & \bl{$\dn$} & \bl{$der\, c\, r_1 + der\, c\, r_2$} & \\ |
322 \bl{der c (r$_1$ $\cdot$ r$_2$)} & \bl{$\dn$} & \bl{if nullable r$_1$}\\ |
438 \bl{$der\, c\, (r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{if $nullable (r_1)$}\\ |
323 & & \bl{then ((der c r$_1$) $\cdot$ r$_2$) + (der c r$_2$)}\\ |
439 & & \bl{then $(der\,c\,r_1) \cdot r_2 + der\, c\, r_2$}\\ |
324 & & \bl{else (der c r$_1$) $\cdot$ r$_2$}\\ |
440 & & \bl{else $(der\, c\, r_1) \cdot r_2$}\\ |
325 \bl{der c (r$^*$)} & \bl{$\dn$} & \bl{(der c r) $\cdot$ (r$^*$)} &\smallskip\\\pause |
441 \bl{$der\, c\, (r^*)$} & \bl{$\dn$} & \bl{$(der\,c\,r) \cdot (r^*)$} &\smallskip\\\pause |
326 |
442 |
327 \bl{ders [] r} & \bl{$\dn$} & \bl{r} & \\ |
443 \bl{$der\!s\, [] r$} & \bl{$\dn$} & \bl{$r$} & \\ |
328 \bl{ders (c::s) r} & \bl{$\dn$} & \bl{ders s (der c r)} & \\ |
444 \bl{$der\!s\, (c\!::\!s) r$} & \bl{$\dn$} & \bl{$der\!s\,s\,(der\,c\,r)$} & \\ |
329 \end{tabular} |
445 \end{tabular} |
330 \end{center} |
446 \end{center} |
331 |
447 |
332 \end{frame}} |
448 \only<3->{ |
333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
449 \begin{textblock}{10.5}(2,5) |
334 |
450 \begin{tikzpicture} |
335 |
451 \draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
336 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
452 {\normalsize\color{darkgray} |
337 \mode<presentation>{ |
453 \begin{minipage}{10.5cm} |
338 \begin{frame}[c] |
454 \hspace{5mm}\mbox{{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
339 \frametitle{\begin{tabular}{c}The Derivative\end{tabular}} |
455 \texttt{\lstinputlisting{../progs/app6.scala}}}} |
|
456 \end{minipage}}; |
|
457 \end{tikzpicture} |
|
458 \end{textblock}} |
|
459 |
|
460 \end{frame}} |
|
461 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
462 |
|
463 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
464 \mode<presentation>{ |
|
465 \begin{frame}[c] |
|
466 \frametitle{\begin{tabular}{c}The Rexp Matcher\end{tabular}} |
340 |
467 |
341 |
468 |
342 {\lstset{language=Scala}\fontsize{8}{10}\selectfont |
469 {\lstset{language=Scala}\fontsize{8}{10}\selectfont |
343 \texttt{\lstinputlisting{app6.scala}}} |
470 \texttt{\lstinputlisting{../progs/app7.scala}}} |
344 |
|
345 |
|
346 |
|
347 \end{frame}} |
|
348 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
349 |
|
350 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
351 \mode<presentation>{ |
|
352 \begin{frame}[c] |
|
353 \frametitle{\begin{tabular}{c}The Rexp Matcher\end{tabular}} |
|
354 |
|
355 |
|
356 {\lstset{language=Scala}\fontsize{8}{10}\selectfont |
|
357 \texttt{\lstinputlisting{app7.scala}}} |
|
358 |
471 |
359 |
472 |
360 |
473 |
361 \end{frame}} |
474 \end{frame}} |
362 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
475 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |