216 \item \bl{$Der\,b\,(Der\,a\,(L(r)))$}\pause |
216 \item \bl{$Der\,b\,(Der\,a\,(L(r)))$}\pause |
217 \item \bl{$Der\,c\,(Der\,b\,(Der\,a\,(L(r))))$}\pause |
217 \item \bl{$Der\,c\,(Der\,b\,(Der\,a\,(L(r))))$}\pause |
218 \item finally we test whether the empty string is in this set\pause\medskip |
218 \item finally we test whether the empty string is in this set\pause\medskip |
219 \end{enumerate} |
219 \end{enumerate} |
220 |
220 |
221 The matching algorithm works similarly, just over regular expression than sets. |
221 The matching algorithm works similarly, just over regular expression instead of sets. |
222 \end{frame}} |
222 \end{frame}} |
223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
224 |
224 |
225 |
225 |
226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
231 |
231 |
232 \begin{enumerate} |
232 \begin{enumerate} |
233 \item \bl{$der\,a\,r$} |
233 \item \bl{$der\,a\,r$} |
234 \item \bl{$der\,b\,(der\,a\,r)$} |
234 \item \bl{$der\,b\,(der\,a\,r)$} |
235 \item \bl{$der\,c\,(der\,b\,(der\,a\,r))$}\bigskip\pause |
235 \item \bl{$der\,c\,(der\,b\,(der\,a\,r))$}\bigskip\pause |
236 \item finally check whether the latter regular expression can match the empty string |
236 \item finally check whether the last regular expression can match the empty string |
237 \end{enumerate} |
237 \end{enumerate} |
238 |
238 |
239 \end{frame}} |
239 \end{frame}} |
240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
241 |
241 |
320 A \alert{regular expression} specifies a language.\bigskip |
324 A \alert{regular expression} specifies a language.\bigskip |
321 |
325 |
322 A language is \alert{regular} iff there exists |
326 A language is \alert{regular} iff there exists |
323 a regular expression that recognises all its strings.\bigskip\bigskip\pause |
327 a regular expression that recognises all its strings.\bigskip\bigskip\pause |
324 |
328 |
325 \textcolor{gray}{not all languages are regular, e.g.~\bl{a$^n$b$^n$}.} |
329 \textcolor{gray}{not all languages are regular, e.g.~\bl{$a^nb^n$}.} |
326 \end{frame}} |
330 \end{frame}} |
327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
328 |
332 |
329 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
330 \mode<presentation>{ |
334 \mode<presentation>{ |
331 \begin{frame}[t] |
335 \begin{frame}[t] |
332 \frametitle{\begin{tabular}{c}Regular Expressions\end{tabular}} |
336 \frametitle{\begin{tabular}{c}Regular Expressions\end{tabular}} |
333 |
337 |
334 \begin{center} |
338 \begin{center} |
335 \begin{tabular}{@ {}rrl@ {\hspace{13mm}}l} |
339 \begin{tabular}{@ {}rrl@ {\hspace{13mm}}l} |
336 \bl{r} & \bl{$::=$} & \bl{$\varnothing$} & null\\ |
340 \bl{$r$} & \bl{$::=$} & \bl{$\varnothing$} & null\\ |
337 & \bl{$\mid$} & \bl{$\epsilon$} & empty string / "" / []\\ |
341 & \bl{$\mid$} & \bl{$\epsilon$} & empty string / "" / $[]$\\ |
338 & \bl{$\mid$} & \bl{c} & character\\ |
342 & \bl{$\mid$} & \bl{$c$} & character\\ |
339 & \bl{$\mid$} & \bl{r$_1$ $\cdot$ r$_2$} & sequence\\ |
343 & \bl{$\mid$} & \bl{$r_1 \cdot r_2$} & sequence\\ |
340 & \bl{$\mid$} & \bl{r$_1$ + r$_2$} & alternative / choice\\ |
344 & \bl{$\mid$} & \bl{$r_1 + r_2$} & alternative / choice\\ |
341 & \bl{$\mid$} & \bl{r$^*$} & star (zero or more)\\ |
345 & \bl{$\mid$} & \bl{$r^*$} & star (zero or more)\\ |
342 \end{tabular}\bigskip |
346 \end{tabular} |
343 \end{center} |
347 \end{center} |
344 |
|
345 How about ranges \bl{[a-z]}, \bl{r$^\text{+}$} and \bl{!r}? |
|
346 |
348 |
|
349 How about ranges \bl{$[a\mbox{-}z]$}, \bl{$r^+$} and \bl{$\sim{}r$}? Do they increase the |
|
350 set of languages we can recognise? |
|
351 |
347 \end{frame}} |
352 \end{frame}} |
348 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
353 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
349 |
354 |
350 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
351 \mode<presentation>{ |
356 \mode<presentation>{ |
352 \begin{frame}[c] |
357 \begin{frame}[c] |
353 \frametitle{\begin{tabular}{c}Negation of Regular Expr's\end{tabular}} |
358 \frametitle{\begin{tabular}{c}Negation of Regular Expr's\end{tabular}} |
354 |
359 |
355 \begin{itemize} |
360 \begin{itemize} |
356 \item \bl{!r} \hspace{6mm} (everything that \bl{r} cannot recognise)\medskip |
361 \item \bl{$\sim{}r$} \hspace{6mm} (everything that \bl{r} cannot recognise)\medskip |
357 \item \bl{$L$(!r) $\dn$ UNIV - $L$(r)}\medskip |
362 \item \bl{$L(\sim{}r) \dn UNIV - L(r)$}\medskip |
358 \item \bl{nullable (!r) $\dn$ not (nullable(r))}\medskip |
363 \item \bl{$nullable (r) \dn not (nullable(r))$}\medskip |
359 \item \bl{der\,c\,(!r) $\dn$ !(der\,c\,r)} |
364 \item \bl{$der\,c\,(\sim{}r) \dn \;\sim{}(der\,c\,r)$} |
360 \end{itemize} |
365 \end{itemize}\bigskip\pause |
361 |
366 |
362 \end{frame}} |
367 Used often for comments: |
363 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
368 |
364 |
369 \[ |
365 |
370 \bl{/ \cdot * \cdot (\sim{}([a\mbox{-}z]^* \cdot * \cdot / \cdot [a\mbox{-}z]^*)) \cdot * \cdot /} |
366 |
371 \] |
367 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
372 |
368 \mode<presentation>{ |
373 |
369 \begin{frame}[c] |
374 \end{frame}} |
370 \frametitle{\begin{tabular}{c}Regular Languages\end{tabular}} |
375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
371 |
376 |
372 A language (a set of strings) is \alert{regular} iff there exists |
377 |
373 a regular expression that recognises all its strings.\bigskip\bigskip\pause |
|
374 |
|
375 |
|
376 Do you think there are languages that are {\bf not} regular? |
|
377 \end{frame}} |
|
378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
379 |
378 |
380 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
379 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
381 \mode<presentation>{ |
380 \mode<presentation>{ |
382 \begin{frame}[c] |
381 \begin{frame}[c] |
383 \frametitle{\begin{tabular}{c}Regular Exp's for Lexing\end{tabular}} |
382 \frametitle{\begin{tabular}{c}Regular Exp's for Lexing\end{tabular}} |