42 |
42 |
43 \end{frame} |
43 \end{frame} |
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
45 |
45 |
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
47 \begin{frame}[c] |
47 \begin{frame}[t] |
48 \frametitle{\begin{tabular}{@ {}c@ {}} |
48 \frametitle{\Large |
49 An Efficient Regular\\[-1mm] |
49 Lets Implement an Efficient\\[-2mm] |
50 Expression Matcher\end{tabular}} |
50 Regular Expression Matcher} |
51 |
51 |
52 \footnotesize |
52 \footnotesize |
53 \begin{center} |
53 \begin{center} |
54 {\normalsize Graphs: \bl{$a^{?\{n\}} \cdot a^{\{n\}}$} and strings \bl{$\underbrace{\,a\ldots a\,}_{n}$}}\smallskip\\ |
54 {\normalsize Graphs: \bl{$a^{?\{n\}} \cdot a^{\{n\}}$} and strings \bl{$\underbrace{\,a\ldots a\,}_{n}$}}\medskip\\ |
55 \begin{tabular}{@{}cc@{}} |
55 \begin{tabular}{@{}cc@{}} |
56 \begin{tikzpicture} |
56 \begin{tikzpicture} |
57 \begin{axis}[ |
57 \begin{axis}[ |
58 xlabel={$n$}, |
58 xlabel={$n$}, |
59 x label style={at={(1.05,0.0)}}, |
59 x label style={at={(1.05,0.0)}}, |
88 scaled ticks=false, |
88 scaled ticks=false, |
89 axis lines=left, |
89 axis lines=left, |
90 width=5cm, |
90 width=5cm, |
91 height=4.5cm, |
91 height=4.5cm, |
92 legend entries={Scala V2,Scala V3}, |
92 legend entries={Scala V2,Scala V3}, |
93 legend pos=north west, |
93 legend pos=north east, |
94 legend cell align=left] |
94 legend cell align=left] |
95 \addplot[green,mark=square*,mark options={fill=white}] table {re2.data}; |
95 \addplot[green,mark=square*,mark options={fill=white}] table {re2.data}; |
96 \addplot[black,mark=square*,mark options={fill=white}] table {re3.data}; |
96 \addplot[black,mark=square*,mark options={fill=white}] table {re3.data}; |
97 \end{axis} |
97 \end{axis} |
98 \end{tikzpicture} |
98 \end{tikzpicture} |
99 \end{tabular} |
99 \end{tabular} |
100 \end{center} |
100 \end{center} |
101 |
101 |
102 \small |
102 \small |
103 In the handouts is a similar graph for \bl{$(a^*)^* \cdot b$} and Java. |
103 In the handouts is a similar graph for \bl{$(a^*)^* \cdot b$} and Java 8. |
104 |
104 |
105 \end{frame} |
105 \end{frame} |
106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
107 |
107 |
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
266 |
269 |
267 \end{frame} |
270 \end{frame} |
268 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
269 |
272 |
270 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
271 \begin{frame}[c] |
274 \begin{frame}[t] |
272 \frametitle{Semantic Derivative} |
275 \frametitle{Semantic Derivative\\[5mm]} |
|
276 |
|
277 |
273 |
278 |
274 \begin{itemize} |
279 \begin{itemize} |
275 \item The \alert{\bf Semantic Derivative} of a |
280 \item The \alert{\bf Semantic Derivative} of a |
276 \underline{language}\\ wrt to a character \bl{$c$}: |
281 \underline{language}\\ w.r.t.~to a character \bl{$c$}: |
277 \bigskip |
282 \bigskip |
278 |
283 |
279 \begin{center} |
284 \begin{center} |
280 \bl{$\Der\,c\,A \dn \{ s \;|\; c\!::\!s \in A\}$ } |
285 \bl{$\Der\,c\,A \dn \{ s \;|\; c\!::\!s \in A\}$ } |
281 \end{center}\bigskip\bigskip\bigskip |
286 \end{center}\bigskip |
282 |
287 |
283 For \bl{$A = \{\textit{foo}, \textit{bar}, \textit{frak}\}$} then |
288 For \bl{$A = \{\textit{foo}, \textit{bar}, \textit{frak}\}$} then |
284 |
289 |
285 \begin{center} |
290 \begin{center} |
286 \bl{\begin{tabular}{l@{\hspace{2mm}}c@{\hspace{2mm}}l} |
291 \bl{\begin{tabular}{l@{\hspace{2mm}}c@{\hspace{2mm}}l} |
287 $\Der\,f\,A$ & $=$ & $\{\textit{oo}, \textit{rak}\}$\\ |
292 $\Der\,f\,A$ & $=$ & $\{\textit{oo}, \textit{rak}\}$\\ |
288 $\Der\,b\,A$ & $=$ & $\{\textit{ar}\}$\\ |
293 $\Der\,b\,A$ & $=$ & $\{\textit{ar}\}$\\ |
289 $\Der\,a\,A$ & $=$ & $\{\}$\\\pause |
294 $\Der\,a\,A$ & $=$ & $\{\}$\pause |
290 \end{tabular}} |
295 \end{tabular}} |
291 \end{center} |
296 \end{center} |
292 |
297 |
293 \small |
298 \small |
294 We can extend this definition to strings |
299 We can extend this definition to strings |
495 \end{frame} |
501 \end{frame} |
496 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
502 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
497 |
503 |
498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
504 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
499 \begin{frame}[c] |
505 \begin{frame}[c] |
500 \frametitle{The Algorithm} |
506 \frametitle{\mbox{The Brzozowski Algorithm}} |
501 |
507 |
502 \begin{center} |
508 \begin{center} |
503 \begin{tabular}{l} |
509 \begin{tabular}{l} |
504 \bl{$\textit{matches}\,r\,s \dn \textit{nullable}(\ders\,r\,s)$} |
510 \bl{$\textit{matches}\,r\,s \dn \textit{nullable}(\ders\;s\;r)$} |
505 \end{tabular} |
511 \end{tabular} |
506 \end{center} |
512 \end{center} |
507 |
513 |
508 |
514 |
509 \end{frame} |
515 \end{frame} |
510 %%%%%%%%%%%%%%%%% |
516 %%%%%%%%%%%%%%%%% |
511 |
517 |
512 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
513 \begin{frame}[t] |
519 \begin{frame}[t] |
514 \frametitle{An Example} |
520 \frametitle{Brzozowski: An Example} |
515 |
521 |
516 Does \bl{$r_1$} match \bl{$abc$}? |
522 Does \bl{$r_1$} match \bl{$abc$}? |
517 \begin{center} |
523 \begin{center} |
518 \begin{tabular}{@{}rl@{}l@{}} |
524 \begin{tabular}{@{}rl@{}l@{}} |
519 Step 1: & build derivative of \bl{$a$} and \bl{$r_1$} & \bl{$(r_2 = \der\,a\,r_1)$}\smallskip\\ |
525 Step 1: & build derivative of \bl{$a$} and \bl{$r_1$} & \bl{$(r_2 = \der\,a\,r_1)$}\smallskip\\ |
520 Step 2: & build derivative of \bl{$b$} and \bl{$r_2$} & \bl{$(r_3 = \der\,b\,r_2)$}\smallskip\\ |
526 Step 2: & build derivative of \bl{$b$} and \bl{$r_2$} & \bl{$(r_3 = \der\,b\,r_2)$}\smallskip\\ |
521 Step 3: & build derivative of \bl{$c$} and \bl{$r_3$} & \bl{$(r_4 = \der\,c\,r_3)$}\smallskip\\ |
527 Step 3: & build derivative of \bl{$c$} and \bl{$r_3$} & \bl{$(r_4 = \der\,c\,r_3)$}\smallskip\\ |
522 Step 4: & the string is exhausted: & \bl{($nullable(r_4))$}\\ |
528 Step 4: & the string is exhausted: & \bl{($nullable(r_4))$}\\ |
523 & test whether \bl{$r_4$} can recognise\\ |
529 & test whether \bl{$r_4$} can recognise\\ |
524 & the empty string\smallskip\\ |
530 & the empty string\medskip\\ |
525 Output: & result of the test\\ |
531 Output: & result of the test\\ |
526 & $\Rightarrow \bl{\textit{true}} \,\text{or}\, |
532 & $\Rightarrow \bl{\textit{true}} \,\text{or}\, |
527 \bl{\textit{false}}$\\ |
533 \bl{\textit{false}}$\\ |
528 \end{tabular} |
534 \end{tabular} |
529 \end{center} |
535 \end{center} |
745 \end{center} |
751 \end{center} |
746 |
752 |
747 \end{frame} |
753 \end{frame} |
748 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
754 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
749 |
755 |
750 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
756 |
751 %\begin{frame}[c] |
757 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
752 %\frametitle{\bl{$(a^*)^* \cdot b$}} |
758 \begin{frame}[c] |
753 % |
759 \frametitle{ |
754 %\begin{center} |
760 Another Example\\[-1mm] |
755 %\begin{tikzpicture} |
761 in Java \liningnums{8} and Python} |
756 % \begin{axis}[ |
762 |
757 % xlabel={$n$}, |
763 \begin{center} |
758 % x label style={at={(1.09,0.0)}}, |
764 \begin{tikzpicture} |
759 % ylabel={time in secs}, |
765 \begin{axis}[ |
760 % enlargelimits=false, |
766 xlabel={$n$}, |
761 % xmax=27, |
767 x label style={at={(1.05,0.0)}}, |
762 % xtick={0,5,...,20}, |
768 ylabel={time in secs}, |
763 % ytick={0,5,...,25}, |
769 enlargelimits=false, |
764 % ymax=13, |
770 xtick={0,5,...,30}, |
765 % scaled ticks=false, |
771 xmax=33, |
766 % axis lines=left, |
772 ymax=35, |
767 % width=9cm, |
773 ytick={0,10,...,30}, |
768 % height=5cm, |
774 scaled ticks=false, |
769 % legend entries={Scala V2}, |
775 axis lines=left, |
770 % legend pos=north west, |
776 width=9cm, |
771 % legend cell align=left] |
777 height=5cm, |
772 %\addplot[green,mark=square*,mark options={fill=white}] table {re2a.data}; |
778 legend entries={Java 8, Python}, |
773 %% still needs to be done |
779 legend pos=north west, |
774 %%\addplot[black,mark=square*,mark options={fill=white}] table {re3a.data}; |
780 legend cell align=left] |
775 %\end{axis} |
781 \addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data}; |
776 %\end{tikzpicture} |
782 \addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data}; |
777 %\end{center} |
783 \end{axis} |
778 % |
784 \end{tikzpicture} |
779 %\end{frame} |
785 \end{center} |
780 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
786 |
781 |
787 Regex: \bl{$(a^*)^* \cdot b$} |
782 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
788 |
783 \begin{frame}[c] |
789 Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$} |
784 \frametitle{\bl{$(a^*)^* \cdot b$}} |
790 |
|
791 \end{frame} |
|
792 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
793 |
|
794 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
795 \begin{frame}[c] |
|
796 \frametitle{Same Example in Java \liningnums{9}+} |
|
797 |
|
798 \begin{center} |
|
799 \begin{tikzpicture} |
|
800 \begin{axis}[ |
|
801 xlabel={$n$}, |
|
802 x label style={at={(1.09,-0.15)}}, |
|
803 ylabel={time in secs}, |
|
804 scaled x ticks=false, |
|
805 enlargelimits=false, |
|
806 xtick distance=10000, |
|
807 xmax=44000, |
|
808 ytick={0,10,...,30}, |
|
809 ymax=35, |
|
810 axis lines=left, |
|
811 width=9cm, |
|
812 height=5cm, |
|
813 legend entries={Java \liningnums{9}+}, |
|
814 legend pos=north west, |
|
815 legend cell align=left] |
|
816 \addplot[blue,mark=square*,mark options={fill=white}] table {re-java9.data}; |
|
817 \end{axis} |
|
818 \end{tikzpicture} |
|
819 \end{center} |
|
820 |
|
821 Regex: \bl{$(a^*)^* \cdot b$} |
|
822 |
|
823 Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$} |
|
824 |
|
825 \end{frame} |
|
826 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
827 |
|
828 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
829 \begin{frame}[c] |
|
830 \frametitle{and with Brzozowski} |
785 |
831 |
786 \begin{center} |
832 \begin{center} |
787 \begin{tikzpicture} |
833 \begin{tikzpicture} |
788 \begin{axis}[ |
834 \begin{axis}[ |
789 xlabel={$n$}, |
835 xlabel={$n$}, |
790 x label style={at={(1.09,0.0)}}, |
836 x label style={at={(1.09,0.0)}}, |
791 ylabel={time in secs}, |
837 ylabel={time in secs}, |
|
838 scaled x ticks=false, |
|
839 xtick distance=2000000, |
792 enlargelimits=false, |
840 enlargelimits=false, |
|
841 xmax=6400000, |
793 ytick={0,10,...,30}, |
842 ytick={0,10,...,30}, |
794 ymax=35, |
843 ymax=35, |
795 axis lines=left, |
844 axis lines=left, |
796 width=9cm, |
845 width=9cm, |
797 height=5cm, |
846 height=5cm, |
798 legend entries={Scala V3}, |
847 legend entries={Scala V3}, |
799 legend pos=north east, |
848 legend pos=north west, |
800 legend cell align=left] |
849 legend cell align=left] |
801 %\addplot[green,mark=square*,mark options={fill=white}] table {re2a.data}; |
850 %\addplot[green,mark=square*,mark options={fill=white}] table {re2a.data}; |
802 \addplot[black,mark=square*,mark options={fill=white}] table {re3a.data}; |
851 \addplot[black,mark=square*,mark options={fill=white}] table {re3a.data}; |
803 \end{axis} |
852 \end{axis} |
804 \end{tikzpicture} |
853 \end{tikzpicture} |
805 \end{center} |
854 \end{center} |
806 |
855 |
807 \end{frame} |
856 Regex: \bl{$(a^*)^* \cdot b$} |
808 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
857 |
809 |
858 Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$} |
810 |
859 |
|
860 \end{frame} |
|
861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
811 |
862 |
812 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
863 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
813 \begin{frame}[t] |
864 \begin{frame}[t] |
814 \frametitle{What is good about this Alg.} |
865 \frametitle{What is good about this Alg.} |
815 |
866 |