author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Mon, 30 Sep 2013 13:18:16 +0100 | |
changeset 117 | 25999de692b2 |
parent 93 | 4794759139ea |
child 118 | 6a5b59690f7d |
permissions | -rw-r--r-- |
7 | 1 |
\documentclass[dvipsnames,14pt,t]{beamer} |
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
2 |
\usepackage{beamerthemeplaincu} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
3 |
%%\usepackage[T1]{fontenc} |
7 | 4 |
\usepackage[latin1]{inputenc} |
5 |
\usepackage{mathpartir} |
|
6 |
\usepackage[absolute,overlay]{textpos} |
|
7 |
\usepackage{ifthen} |
|
8 |
\usepackage{tikz} |
|
9 |
\usepackage{pgf} |
|
10 |
\usepackage{calc} |
|
11 |
\usepackage{ulem} |
|
12 |
\usepackage{courier} |
|
13 |
\usepackage{listings} |
|
14 |
\renewcommand{\uline}[1]{#1} |
|
15 |
\usetikzlibrary{arrows} |
|
16 |
\usetikzlibrary{automata} |
|
17 |
\usetikzlibrary{shapes} |
|
18 |
\usetikzlibrary{shadows} |
|
19 |
\usetikzlibrary{positioning} |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
20 |
\usetikzlibrary{plotmarks} |
7 | 21 |
\usetikzlibrary{calc} |
22 |
\usepackage{graphicx} |
|
23 |
||
24 |
\definecolor{javared}{rgb}{0.6,0,0} % for strings |
|
25 |
\definecolor{javagreen}{rgb}{0.25,0.5,0.35} % comments |
|
26 |
\definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords |
|
27 |
\definecolor{javadocblue}{rgb}{0.25,0.35,0.75} % javadoc |
|
28 |
||
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
29 |
\makeatletter |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
30 |
\lst@CCPutMacro\lst@ProcessOther {"2D}{\lst@ttfamily{-{}}{-{}}} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
31 |
\@empty\z@\@empty |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
32 |
\makeatother |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
33 |
|
7 | 34 |
\lstset{language=Java, |
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
35 |
basicstyle=\consolas, |
7 | 36 |
keywordstyle=\color{javapurple}\bfseries, |
37 |
stringstyle=\color{javagreen}, |
|
38 |
commentstyle=\color{javagreen}, |
|
39 |
morecomment=[s][\color{javadocblue}]{/**}{*/}, |
|
40 |
numbers=left, |
|
41 |
numberstyle=\tiny\color{black}, |
|
42 |
stepnumber=1, |
|
43 |
numbersep=10pt, |
|
44 |
tabsize=2, |
|
45 |
showspaces=false, |
|
46 |
showstringspaces=false} |
|
47 |
||
48 |
\lstdefinelanguage{scala}{ |
|
49 |
morekeywords={abstract,case,catch,class,def,% |
|
50 |
do,else,extends,false,final,finally,% |
|
51 |
for,if,implicit,import,match,mixin,% |
|
52 |
new,null,object,override,package,% |
|
53 |
private,protected,requires,return,sealed,% |
|
54 |
super,this,throw,trait,true,try,% |
|
55 |
type,val,var,while,with,yield}, |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
56 |
otherkeywords={=>,<-,<\%,<:,>:,\#,@,->}, |
7 | 57 |
sensitive=true, |
58 |
morecomment=[l]{//}, |
|
59 |
morecomment=[n]{/*}{*/}, |
|
60 |
morestring=[b]", |
|
61 |
morestring=[b]', |
|
62 |
morestring=[b]""" |
|
63 |
} |
|
64 |
||
65 |
\lstset{language=Scala, |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
66 |
basicstyle=\consolas, |
7 | 67 |
keywordstyle=\color{javapurple}\bfseries, |
68 |
stringstyle=\color{javagreen}, |
|
69 |
commentstyle=\color{javagreen}, |
|
70 |
morecomment=[s][\color{javadocblue}]{/**}{*/}, |
|
71 |
numbers=left, |
|
72 |
numberstyle=\tiny\color{black}, |
|
73 |
stepnumber=1, |
|
74 |
numbersep=10pt, |
|
75 |
tabsize=2, |
|
76 |
showspaces=false, |
|
77 |
showstringspaces=false} |
|
78 |
||
79 |
% beamer stuff |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
80 |
\renewcommand{\slidecaption}{AFL 02, King's College London, 2.~October 2013} |
11 | 81 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}} |
82 |
\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions |
|
7 | 83 |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
84 |
% The data files, written on the first run. |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
85 |
\begin{filecontents}{re-python.data} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
86 |
1 0.029 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
87 |
5 0.029 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
88 |
10 0.029 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
89 |
15 0.032 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
90 |
16 0.042 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
91 |
17 0.042 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
92 |
18 0.055 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
93 |
19 0.084 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
94 |
20 0.136 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
95 |
21 0.248 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
96 |
22 0.464 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
97 |
23 0.899 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
98 |
24 1.773 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
99 |
25 3.505 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
100 |
26 6.993 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
101 |
27 14.503 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
102 |
28 29.307 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
103 |
#29 58.886 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
104 |
\end{filecontents} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
105 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
106 |
\begin{filecontents}{re-ruby.data} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
107 |
1 0.00006 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
108 |
2 0.00003 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
109 |
3 0.00001 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
110 |
4 0.00001 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
111 |
5 0.00001 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
112 |
6 0.00002 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
113 |
7 0.00002 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
114 |
8 0.00004 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
115 |
9 0.00007 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
116 |
10 0.00013 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
117 |
11 0.00026 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
118 |
12 0.00055 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
119 |
13 0.00106 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
120 |
14 0.00196 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
121 |
15 0.00378 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
122 |
16 0.00764 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
123 |
17 0.01606 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
124 |
18 0.03094 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
125 |
19 0.06508 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
126 |
20 0.12420 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
127 |
21 0.25393 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
128 |
22 0.51449 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
129 |
23 1.02174 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
130 |
24 2.05998 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
131 |
25 4.22514 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
132 |
26 8.42479 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
133 |
27 16.88678 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
134 |
28 34.79653 |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
135 |
\end{filecontents} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
136 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
137 |
|
7 | 138 |
\begin{document} |
139 |
||
140 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
141 |
\mode<presentation>{ |
|
142 |
\begin{frame}<1>[t] |
|
143 |
\frametitle{% |
|
144 |
\begin{tabular}{@ {}c@ {}} |
|
145 |
\\[-3mm] |
|
146 |
\LARGE Automata and \\[-2mm] |
|
16 | 147 |
\LARGE Formal Languages (2)\\[3mm] |
7 | 148 |
\end{tabular}} |
149 |
||
16 | 150 |
%\begin{center} |
151 |
%\includegraphics[scale=0.3]{pics/ante1.jpg}\hspace{5mm} |
|
152 |
%\includegraphics[scale=0.31]{pics/ante2.jpg}\\ |
|
153 |
%\footnotesize\textcolor{gray}{Antikythera automaton, 100 BC (Archimedes?)} |
|
154 |
%\end{center} |
|
7 | 155 |
|
156 |
\normalsize |
|
157 |
\begin{center} |
|
158 |
\begin{tabular}{ll} |
|
159 |
Email: & christian.urban at kcl.ac.uk\\ |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
160 |
Office: & S1.27 (1st floor Strand Building)\\ |
16 | 161 |
Slides: & KEATS |
7 | 162 |
\end{tabular} |
163 |
\end{center} |
|
164 |
||
165 |
||
166 |
\end{frame}} |
|
167 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
168 |
||
169 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
170 |
\mode<presentation>{ |
|
16 | 171 |
\begin{frame}[c] |
172 |
\frametitle{\begin{tabular}{c}Languages\end{tabular}} |
|
173 |
||
174 |
A \alert{language} is a set of strings.\bigskip |
|
175 |
||
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
176 |
A \alert{regular expression} specifies a set of strings, or language. |
16 | 177 |
|
178 |
\end{frame}} |
|
179 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
180 |
||
181 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
182 |
\mode<presentation>{ |
|
15 | 183 |
\begin{frame}[t] |
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
184 |
\frametitle{\begin{tabular}{c}Strings\end{tabular}} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
185 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
186 |
Different ways of writing strings: |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
187 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
188 |
\begin{center} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
189 |
\begin{tabular}{ccc} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
190 |
\bl{\consolas"$hello$"}\quad{} & \bl{$[h, e, l, l, o]$} & \quad\bl{$h\!::\!e\!::\!l\!::\!l\!::\!o\!::\!N\!il$}\bigskip\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
191 |
\bl{\consolas ""} & \bl{$[]$} & \bl{$N$\!$il$} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
192 |
\end{tabular} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
193 |
\end{center}\pause |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
194 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
195 |
The concatenation operation on strings and sets of strings: |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
196 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
197 |
\begin{center} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
198 |
\begin{tabular}{l} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
199 |
\bl{{\consolas"$f\!oo$"}$\;@\;${\consolas"$bar$"}$\;=\;${\consolas"$f\!oobar$"}}\medskip\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
200 |
\bl{$A \;@\; B \dn \{ s_1 @ s_2 \mid s_1 \in A \wedge s_2 \in B\}$} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
201 |
\end{tabular} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
202 |
\end{center} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
203 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
204 |
\end{frame}} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
205 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
206 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
207 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
208 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
209 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
210 |
\mode<presentation>{ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
211 |
\begin{frame}[t] |
7 | 212 |
\frametitle{\begin{tabular}{c}Regular Expressions\end{tabular}} |
213 |
||
15 | 214 |
Their inductive definition: |
215 |
||
216 |
||
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
217 |
\begin{textblock}{6}(2,6.5) |
7 | 218 |
\begin{tabular}{@ {}rrl@ {\hspace{13mm}}l} |
219 |
\bl{r} & \bl{$::=$} & \bl{$\varnothing$} & null\\ |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
220 |
& \bl{$\mid$} & \bl{$\epsilon$} & empty string / {\consolas""} / $[]$\\ |
7 | 221 |
& \bl{$\mid$} & \bl{c} & character\\ |
222 |
& \bl{$\mid$} & \bl{r$_1$ $\cdot$ r$_2$} & sequence\\ |
|
223 |
& \bl{$\mid$} & \bl{r$_1$ + r$_2$} & alternative / choice\\ |
|
224 |
& \bl{$\mid$} & \bl{r$^*$} & star (zero or more)\\ |
|
225 |
\end{tabular} |
|
226 |
\end{textblock} |
|
227 |
||
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
228 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
229 |
\only<2->{ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
230 |
\begin{textblock}{9}(4,0.5) |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
231 |
\begin{tikzpicture} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
232 |
\draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
233 |
{\normalsize\color{darkgray} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
234 |
\begin{minipage}{9cm} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
235 |
\hspace{5mm}\mbox{{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
236 |
\texttt{\lstinputlisting{../progs/app51.scala}}}} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
237 |
\end{minipage}}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
238 |
\end{tikzpicture} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
239 |
\end{textblock}} |
16 | 240 |
|
241 |
\end{frame}} |
|
242 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
243 |
||
244 |
||
245 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
246 |
\mode<presentation>{ |
|
7 | 247 |
\begin{frame}[c] |
248 |
\frametitle{\begin{tabular}{c}The Meaning of a\\[-2mm] Regular Expression\end{tabular}} |
|
249 |
||
250 |
\begin{textblock}{15}(1,4) |
|
251 |
\begin{tabular}{@ {}rcl} |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
252 |
\bl{$L(\varnothing)$} & \bl{$\dn$} & \bl{$\varnothing$}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
253 |
\bl{$L(\epsilon)$} & \bl{$\dn$} & \bl{$\{$""$\}$}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
254 |
\bl{$L(c)$} & \bl{$\dn$} & \bl{$\{"c"\}$}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
255 |
\bl{$L(r_1 + r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
256 |
\bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \,@\, L(r_2)$}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
257 |
\bl{$L(r^*)$} & \bl{$\dn$} & \bl{$\bigcup_{n \ge 0} L(r)^n$}\\ |
7 | 258 |
\end{tabular}\bigskip |
259 |
||
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
260 |
\only<2->{ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
261 |
\hspace{5mm}\textcolor{blue}{$L(r)^0 \;\dn\; \{""\}$}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
262 |
\textcolor{blue}{$L(r)^{n+1} \;\dn\; L(r) \,@\, L(r)^n$}} |
11 | 263 |
\end{textblock} |
7 | 264 |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
265 |
|
16 | 266 |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
267 |
\only<1->{ |
16 | 268 |
\begin{textblock}{6}(9,12)\small |
269 |
\bl{$L$} is a function from regular expressions to sets of strings\\ |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
270 |
\bl{$L$ : Rexp $\Rightarrow$ Set$[$String$]$} |
16 | 271 |
\end{textblock}} |
272 |
||
273 |
||
7 | 274 |
\end{frame}} |
275 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
276 |
||
16 | 277 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
278 |
\mode<presentation>{ |
|
279 |
\begin{frame}[c] |
|
280 |
||
281 |
\large |
|
282 |
\begin{center} |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
283 |
What is \bl{$L(a^*)$}? |
16 | 284 |
\end{center} |
285 |
||
286 |
\end{frame}} |
|
287 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
288 |
||
289 |
||
290 |
||
11 | 291 |
\newcommand{\YES}{\textcolor{gray}{yes}} |
292 |
\newcommand{\NO}{\textcolor{gray}{no}} |
|
293 |
\newcommand{\FORALLR}{\textcolor{gray}{$\forall$ r.}} |
|
7 | 294 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
295 |
\mode<presentation>{ |
|
296 |
\begin{frame}[c] |
|
11 | 297 |
\frametitle{\begin{tabular}{c}Reg Exp Equivalences\end{tabular}} |
7 | 298 |
|
299 |
\begin{center} |
|
16 | 300 |
\begin{tabular}{l@ {\hspace{7mm}}rcl@ {\hspace{7mm}}l} |
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
301 |
&\bl{$(a + b) + c$} & \bl{$\equiv^?$} & \bl{$a + (b + c)$} & \onslide<2->{\YES}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
302 |
&\bl{$a + a$} & \bl{$\equiv^?$} & \bl{$a$} & \onslide<3->{\YES}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
303 |
&\bl{$(a \cdot b) \cdot c$} & \bl{$\equiv^?$} & \bl{$a \cdot (b \cdot c)$} & \onslide<4->{\YES}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
304 |
&\bl{$a \cdot a$} & \bl{$\equiv^?$} & \bl{$a$} & \onslide<5->{\NO}\\ |
11 | 305 |
&\bl{$\epsilon^*$} & \bl{$\equiv^?$} & \bl{$\epsilon$} & \onslide<6->{\YES}\\ |
306 |
&\bl{$\varnothing^*$} & \bl{$\equiv^?$} & \bl{$\varnothing$} & \onslide<7->{\NO}\\ |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
307 |
\FORALLR &\bl{$r \cdot \epsilon$} & \bl{$\equiv^?$} & \bl{$r$} & \onslide<8->{\YES}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
308 |
\FORALLR &\bl{$r + \epsilon$} & \bl{$\equiv^?$} & \bl{$r$} & \onslide<9->{\NO}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
309 |
\FORALLR &\bl{$r + \varnothing$} & \bl{$\equiv^?$} & \bl{$r$} & \onslide<10->{\YES}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
310 |
\FORALLR &\bl{$r \cdot \varnothing$} & \bl{$\equiv^?$} & \bl{$r$} & \onslide<11->{\NO}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
311 |
&\bl{$c \cdot (a + b)$} & \bl{$\equiv^?$} & \bl{$(c \cdot a) + (c \cdot b)$} & \onslide<12->{\YES}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
312 |
&\bl{$a^*$} & \bl{$\equiv^?$} & \bl{$\epsilon + (a \cdot a^*)$} & \onslide<13->{\YES} |
11 | 313 |
\end{tabular} |
7 | 314 |
\end{center} |
315 |
||
316 |
\end{frame}} |
|
317 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
318 |
||
319 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
320 |
\mode<presentation>{ |
|
321 |
\begin{frame}[c] |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
322 |
\frametitle{\begin{tabular}{c}The Specification\\[-1mm] of Matching\end{tabular}} |
11 | 323 |
|
324 |
\large |
|
325 |
a regular expression \bl{r} matches a string \bl{s} is defined as |
|
326 |
||
327 |
\begin{center} |
|
328 |
\bl{s $\in$ $L$(r)}\\ |
|
329 |
\end{center}\bigskip\bigskip\pause |
|
330 |
||
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
331 |
\end{frame}} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
332 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
333 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
334 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
335 |
\mode<presentation>{ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
336 |
\begin{frame}[t] |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
337 |
\frametitle{\begin{tabular}{c}\bl{$(a?\{n\}) \cdot a\{n\}$}\end{tabular}} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
338 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
339 |
\mbox{}\\[-13mm] |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
340 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
341 |
\begin{tikzpicture}[y=.2cm, x=.3cm] |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
342 |
%axis |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
343 |
\draw (0,0) -- coordinate (x axis mid) (30,0); |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
344 |
\draw (0,0) -- coordinate (y axis mid) (0,30); |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
345 |
%ticks |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
346 |
\foreach \x in {0,5,...,30} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
347 |
\draw (\x,1pt) -- (\x,-3pt) |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
348 |
node[anchor=north] {\x}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
349 |
\foreach \y in {0,5,...,30} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
350 |
\draw (1pt,\y) -- (-3pt,\y) |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
351 |
node[anchor=east] {\y}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
352 |
%labels |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
353 |
\node[below=0.6cm] at (x axis mid) {\bl{a}s}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
354 |
\node[rotate=90, left=1.2cm] at (y axis mid) {secs}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
355 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
356 |
%plots |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
357 |
\draw[color=blue] plot[mark=*, mark options={fill=white}] |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
358 |
file {re-python.data}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
359 |
\draw[color=red] plot[mark=triangle*, mark options={fill=white} ] |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
360 |
file {re1.data}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
361 |
\draw[color=green] plot[mark=square*, mark options={fill=white} ] |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
362 |
file {re2.data}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
363 |
\draw[color=brown] plot[mark=pentagon*, mark options={fill=white} ] |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
364 |
file {re-ruby.data}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
365 |
|
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
366 |
%legend |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
367 |
\begin{scope}[shift={(4,20)}] |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
368 |
\draw[color=blue] (0,0) -- |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
369 |
plot[mark=*, mark options={fill=white}] (0.25,0) -- (0.5,0) |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
370 |
node[right]{\small Python}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
371 |
\draw[yshift=-\baselineskip, color=brown] (0,0) -- |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
372 |
plot[mark=pentagon*, mark options={fill=white}] (0.25,0) -- (0.5,0) |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
373 |
node[right]{\small Ruby}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
374 |
\end{scope} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
375 |
\end{tikzpicture} |
11 | 376 |
|
377 |
\end{frame}} |
|
378 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
379 |
||
380 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
381 |
\mode<presentation>{ |
|
382 |
\begin{frame}[t] |
|
383 |
\frametitle{\begin{tabular}{c}A Matching Algorithm\end{tabular}} |
|
384 |
||
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
385 |
\small |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
386 |
\ldots{}whether a regular expression can match the empty string: |
11 | 387 |
\begin{center} |
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
388 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
389 |
\bl{$nullable(\varnothing)$} & \bl{$\dn$} & \bl{$f\!\/alse$}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
390 |
\bl{$nullable(\epsilon)$} & \bl{$\dn$} & \bl{$true$}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
391 |
\bl{$nullable (c)$} & \bl{$\dn$} & \bl{$f\!alse$}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
392 |
\bl{$nullable (r_1 + r_2)$} & \bl{$\dn$} & \bl{$nullable(r_1) \vee nullable(r_2)$} \\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
393 |
\bl{$nullable (r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$nullable(r_1) \wedge nullable(r_2)$} \\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
394 |
\bl{$nullable (r^*)$} & \bl{$\dn$} & \bl{$true$} \\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
395 |
\end{tabular} |
16 | 396 |
\end{center} |
397 |
||
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
398 |
\only<2->{ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
399 |
\begin{textblock}{9}(3.4,10) |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
400 |
\begin{tikzpicture} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
401 |
\draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
402 |
{\normalsize\color{darkgray} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
403 |
\begin{minipage}{9cm} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
404 |
\hspace{5mm}\mbox{{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
405 |
\texttt{\lstinputlisting{../progs/app5.scala}}}} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
406 |
\end{minipage}}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
407 |
\end{tikzpicture} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
408 |
\end{textblock}} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
409 |
|
11 | 410 |
\end{frame}} |
411 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
412 |
||
413 |
||
414 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
415 |
\mode<presentation>{ |
|
416 |
\begin{frame}[c] |
|
15 | 417 |
\frametitle{\begin{tabular}{c}The Derivative of a Rexp\end{tabular}} |
7 | 418 |
|
419 |
\large |
|
420 |
If \bl{r} matches the string \bl{c::s}, what is a regular expression that matches \bl{s}?\bigskip\bigskip\bigskip\bigskip |
|
421 |
||
422 |
\small |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
423 |
\bl{$der\,c\,r$} gives the answer |
7 | 424 |
\end{frame}} |
425 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
426 |
||
427 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
428 |
\mode<presentation>{ |
|
429 |
\begin{frame}[c] |
|
19 | 430 |
\frametitle{\begin{tabular}{c}The Derivative of a Rexp (2)\end{tabular}} |
7 | 431 |
|
432 |
\begin{center} |
|
433 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {\hspace{-10mm}}l@ {}} |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
434 |
\bl{$der\, c\, (\varnothing)$} & \bl{$\dn$} & \bl{$\varnothing$} & \\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
435 |
\bl{$der\, c\, (\epsilon)$} & \bl{$\dn$} & \bl{$\varnothing$} & \\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
436 |
\bl{$der\, c\, (d)$} & \bl{$\dn$} & \bl{if $c = d$ then $\epsilon$ else $\varnothing$} & \\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
437 |
\bl{$der\, c\, (r_1 + r_2)$} & \bl{$\dn$} & \bl{$der\, c\, r_1 + der\, c\, r_2$} & \\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
438 |
\bl{$der\, c\, (r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{if $nullable (r_1)$}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
439 |
& & \bl{then $(der\,c\,r_1) \cdot r_2 + der\, c\, r_2$}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
440 |
& & \bl{else $(der\, c\, r_1) \cdot r_2$}\\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
441 |
\bl{$der\, c\, (r^*)$} & \bl{$\dn$} & \bl{$(der\,c\,r) \cdot (r^*)$} &\smallskip\\\pause |
7 | 442 |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
443 |
\bl{$der\!s\, [] r$} & \bl{$\dn$} & \bl{$r$} & \\ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
444 |
\bl{$der\!s\, (c\!::\!s) r$} & \bl{$\dn$} & \bl{$der\!s\,s\,(der\,c\,r)$} & \\ |
7 | 445 |
\end{tabular} |
446 |
\end{center} |
|
447 |
||
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
448 |
\only<3->{ |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
449 |
\begin{textblock}{10.5}(2,5) |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
450 |
\begin{tikzpicture} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
451 |
\draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
452 |
{\normalsize\color{darkgray} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
453 |
\begin{minipage}{10.5cm} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
454 |
\hspace{5mm}\mbox{{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
455 |
\texttt{\lstinputlisting{../progs/app6.scala}}}} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
456 |
\end{minipage}}; |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
457 |
\end{tikzpicture} |
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
458 |
\end{textblock}} |
7 | 459 |
|
460 |
\end{frame}} |
|
461 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
462 |
||
463 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
464 |
\mode<presentation>{ |
|
465 |
\begin{frame}[c] |
|
466 |
\frametitle{\begin{tabular}{c}The Rexp Matcher\end{tabular}} |
|
467 |
||
468 |
||
469 |
{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
|
117
25999de692b2
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
470 |
\texttt{\lstinputlisting{../progs/app7.scala}}} |
7 | 471 |
|
472 |
||
473 |
||
474 |
\end{frame}} |
|
475 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
476 |
||
17 | 477 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
478 |
\mode<presentation>{ |
|
479 |
\begin{frame}[t] |
|
480 |
\frametitle{\begin{tabular}{c}Proofs about Rexp\end{tabular}} |
|
481 |
||
482 |
Remember their inductive definition:\\[5cm] |
|
483 |
||
484 |
\begin{textblock}{6}(5,5) |
|
485 |
\begin{tabular}{@ {}rrl} |
|
486 |
\bl{r} & \bl{$::=$} & \bl{$\varnothing$}\\ |
|
487 |
& \bl{$\mid$} & \bl{$\epsilon$} \\ |
|
488 |
& \bl{$\mid$} & \bl{c} \\ |
|
489 |
& \bl{$\mid$} & \bl{r$_1$ $\cdot$ r$_2$}\\ |
|
490 |
& \bl{$\mid$} & \bl{r$_1$ + r$_2$} \\ |
|
491 |
& \bl{$\mid$} & \bl{r$^*$} \\ |
|
492 |
\end{tabular} |
|
493 |
\end{textblock} |
|
494 |
||
495 |
If we want to prove something, say a property \bl{$P$(r)}, for all regular expressions \bl{r} then \ldots |
|
496 |
||
497 |
\end{frame}} |
|
498 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
499 |
||
500 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
501 |
\mode<presentation>{ |
|
502 |
\begin{frame}[c] |
|
503 |
\frametitle{\begin{tabular}{c}Proofs about Rexp (2)\end{tabular}} |
|
504 |
||
505 |
\begin{itemize} |
|
506 |
\item \bl{$P$} holds for \bl{$\varnothing$}, \bl{$\epsilon$} and \bl{c}\bigskip |
|
507 |
\item \bl{$P$} holds for \bl{r$_1$ + r$_2$} under the assumption that \bl{$P$} already |
|
508 |
holds for \bl{r$_1$} and \bl{r$_2$}.\bigskip |
|
509 |
\item \bl{$P$} holds for \bl{r$_1$ $\cdot$ r$_2$} under the assumption that \bl{$P$} already |
|
510 |
holds for \bl{r$_1$} and \bl{r$_2$}. |
|
511 |
\item \bl{$P$} holds for \bl{r$^*$} under the assumption that \bl{$P$} already |
|
512 |
holds for \bl{r}. |
|
513 |
\end{itemize} |
|
514 |
||
515 |
\end{frame}} |
|
516 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
517 |
||
518 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
519 |
\mode<presentation>{ |
|
520 |
\begin{frame}[c] |
|
521 |
\frametitle{\begin{tabular}{c}Proofs about Rexp (3)\end{tabular}} |
|
522 |
||
523 |
Assume \bl{$P(r)$} is the property: |
|
524 |
||
525 |
\begin{center} |
|
526 |
\bl{nullable(r)} if and only if \bl{"" $\in$ $L$(r)} |
|
527 |
\end{center} |
|
528 |
||
529 |
\end{frame}} |
|
530 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
531 |
||
532 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
533 |
\mode<presentation>{ |
|
534 |
\begin{frame}[c] |
|
535 |
\frametitle{\begin{tabular}{c}Proofs about Strings\end{tabular}} |
|
536 |
||
537 |
If we want to prove something, say a property \bl{$P$(s)}, for all strings \bl{s} then \ldots\bigskip |
|
538 |
||
539 |
\begin{itemize} |
|
540 |
\item \bl{$P$} holds for the empty string, and\medskip |
|
541 |
\item \bl{$P$} holds for the string \bl{c::s} under the assumption that \bl{$P$} |
|
542 |
already holds for \bl{s} |
|
543 |
\end{itemize} |
|
544 |
\end{frame}} |
|
545 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
546 |
||
19 | 547 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
548 |
\mode<presentation>{ |
|
549 |
\begin{frame}[c] |
|
550 |
\frametitle{\begin{tabular}{c}Proofs about Strings (2)\end{tabular}} |
|
551 |
||
552 |
Let \bl{Der c A} be the set defined as |
|
553 |
||
554 |
\begin{center} |
|
555 |
\bl{Der c A $\dn$ $\{$ s $|$ c::s $\in$ A$\}$ } |
|
556 |
\end{center} |
|
557 |
||
558 |
Assume that \bl{$L$(der c r) = Der c ($L$(r))}. Prove that |
|
559 |
||
560 |
\begin{center} |
|
561 |
\bl{matcher(r, s) if and only if s $\in$ $L$(r)} |
|
562 |
\end{center} |
|
563 |
||
564 |
||
565 |
\end{frame}} |
|
566 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
17 | 567 |
|
568 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
569 |
\mode<presentation>{ |
|
570 |
\begin{frame}[c] |
|
571 |
\frametitle{\begin{tabular}{c}Regular Languages\end{tabular}} |
|
572 |
||
573 |
A language (set of strings) is \alert{regular} iff there exists |
|
574 |
a regular expression that recognises all its strings. |
|
575 |
||
576 |
\end{frame}} |
|
577 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
578 |
||
579 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
580 |
\mode<presentation>{ |
|
581 |
\begin{frame}[c] |
|
582 |
\frametitle{\begin{tabular}{c}Automata\end{tabular}} |
|
583 |
||
584 |
A deterministic finite automaton consists of: |
|
585 |
||
586 |
\begin{itemize} |
|
587 |
\item a set of states |
|
588 |
\item one of these states is the start state |
|
589 |
\item some states are accepting states, and |
|
590 |
\item there is transition function\medskip |
|
591 |
||
592 |
\small |
|
593 |
which takes a state as argument and a character and produces a new state\smallskip\\ |
|
594 |
this function might not always be defined |
|
595 |
\end{itemize} |
|
596 |
||
597 |
\end{frame}} |
|
598 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
599 |
||
7 | 600 |
|
601 |
\end{document} |
|
602 |
||
603 |
%%% Local Variables: |
|
604 |
%%% mode: latex |
|
605 |
%%% TeX-master: t |
|
606 |
%%% End: |
|
607 |