16
|
1 |
(*<*)
|
24
|
2 |
theory Slides
|
203
|
3 |
imports "~~/src/HOL/Library/LaTeXsugar"
|
16
|
4 |
begin
|
|
5 |
|
|
6 |
notation (latex output)
|
|
7 |
set ("_") and
|
|
8 |
Cons ("_::/_" [66,65] 65)
|
|
9 |
|
|
10 |
(*>*)
|
|
11 |
|
|
12 |
|
|
13 |
text_raw {*
|
24
|
14 |
%\renewcommand{\slidecaption}{Cambridge, 9 November 2010}
|
|
15 |
\renewcommand{\slidecaption}{Munich, 17 November 2010}
|
16
|
16 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
17 |
\mode<presentation>{
|
|
18 |
\begin{frame}
|
|
19 |
\frametitle{%
|
|
20 |
\begin{tabular}{@ {}c@ {}}
|
21
|
21 |
\LARGE A Formalisation of the\\[-3mm]
|
|
22 |
\LARGE Myhill-Nerode Theorem\\[-3mm]
|
|
23 |
\LARGE based on Regular Expressions\\[-3mm]
|
|
24 |
\large \onslide<2>{\alert{or, Regular Languages Done Right}}\\
|
16
|
25 |
\end{tabular}}
|
|
26 |
|
|
27 |
\begin{center}
|
|
28 |
Christian Urban
|
|
29 |
\end{center}
|
|
30 |
|
|
31 |
|
|
32 |
\begin{center}
|
|
33 |
joint work with Chunhan Wu and Xingyuan Zhang from the PLA
|
|
34 |
University of Science and Technology in Nanjing
|
|
35 |
\end{center}
|
|
36 |
|
|
37 |
\end{frame}}
|
|
38 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
39 |
|
|
40 |
*}
|
|
41 |
|
|
42 |
text_raw {*
|
|
43 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
44 |
\mode<presentation>{
|
|
45 |
\begin{frame}[c]
|
24
|
46 |
\frametitle{In Most Textbooks\ldots}
|
16
|
47 |
|
|
48 |
\begin{itemize}
|
24
|
49 |
\item A \alert{regular language} is one where there is a DFA that
|
|
50 |
recognises it.\bigskip\pause
|
|
51 |
\end{itemize}
|
|
52 |
|
16
|
53 |
|
24
|
54 |
I can think of three reasons why this is a good definition:\medskip
|
|
55 |
\begin{itemize}
|
|
56 |
\item string matching via DFAs (yacc)
|
|
57 |
\item pumping lemma
|
|
58 |
\item closure properties of regular languages (closed under complement)
|
16
|
59 |
\end{itemize}
|
|
60 |
|
|
61 |
\end{frame}}
|
|
62 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
63 |
|
|
64 |
*}
|
|
65 |
|
|
66 |
|
|
67 |
text_raw {*
|
|
68 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
69 |
\mode<presentation>{
|
21
|
70 |
\begin{frame}[t]
|
16
|
71 |
\frametitle{Really Bad News!}
|
|
72 |
|
24
|
73 |
DFAs are bad news for formalisations in theorem provers. They might
|
|
74 |
be represented as:
|
16
|
75 |
|
|
76 |
\begin{itemize}
|
|
77 |
\item graphs
|
|
78 |
\item matrices
|
|
79 |
\item partial functions
|
|
80 |
\end{itemize}
|
|
81 |
|
24
|
82 |
All constructions are messy to reason about.\bigskip\bigskip
|
16
|
83 |
\pause
|
|
84 |
|
|
85 |
\small
|
24
|
86 |
\only<2>{Alexander and Tobias: ``\ldots automata theory \ldots does not come for free \ldots''}
|
|
87 |
\only<3>{
|
16
|
88 |
Constable et al needed (on and off) 18 months for a 3-person team
|
|
89 |
to formalise automata theory in Nuprl including Myhill-Nerode. There is
|
|
90 |
only very little other formalised work on regular languages I know of
|
21
|
91 |
in Coq, Isabelle and HOL.}
|
24
|
92 |
\only<4>{typical textbook reasoning goes like: ``\ldots if \smath{M} and \smath{N} are any two
|
21
|
93 |
automata with no inaccessible states \ldots''
|
|
94 |
}
|
16
|
95 |
|
|
96 |
\end{frame}}
|
|
97 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
98 |
|
|
99 |
*}
|
|
100 |
|
|
101 |
text_raw {*
|
|
102 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
103 |
\mode<presentation>{
|
21
|
104 |
\begin{frame}[t]
|
16
|
105 |
\frametitle{Regular Expressions}
|
|
106 |
|
21
|
107 |
\ldots are a simple datatype:
|
16
|
108 |
|
|
109 |
\only<1>{
|
|
110 |
\begin{center}\color{blue}
|
|
111 |
\begin{tabular}{rcl}
|
|
112 |
rexp & $::=$ & NULL\\
|
|
113 |
& $\mid$ & EMPTY\\
|
|
114 |
& $\mid$ & CHR c\\
|
|
115 |
& $\mid$ & ALT rexp rexp\\
|
|
116 |
& $\mid$ & SEQ rexp rexp\\
|
|
117 |
& $\mid$ & STAR rexp
|
|
118 |
\end{tabular}
|
|
119 |
\end{center}}
|
|
120 |
\only<2->{
|
|
121 |
\begin{center}
|
|
122 |
\begin{tabular}{rcl}
|
21
|
123 |
\smath{r} & \smath{::=} & \smath{0} \\
|
16
|
124 |
& \smath{\mid} & \smath{[]}\\
|
|
125 |
& \smath{\mid} & \smath{c}\\
|
|
126 |
& \smath{\mid} & \smath{r_1 + r_2}\\
|
21
|
127 |
& \smath{\mid} & \smath{r_1 \cdot r_2}\\
|
16
|
128 |
& \smath{\mid} & \smath{r^\star}
|
|
129 |
\end{tabular}
|
|
130 |
\end{center}}
|
|
131 |
|
21
|
132 |
\only<3->{Induction and recursion principles come for free.}
|
|
133 |
|
|
134 |
\end{frame}}
|
|
135 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
136 |
|
|
137 |
*}
|
|
138 |
|
|
139 |
|
|
140 |
text_raw {*
|
|
141 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
142 |
\mode<presentation>{
|
|
143 |
\begin{frame}[c]
|
|
144 |
\frametitle{Semantics of Rexps}
|
|
145 |
|
|
146 |
\begin{center}
|
|
147 |
\begin{tabular}{rcl}
|
|
148 |
\smath{\mathbb{L}(0)} & \smath{=} & \smath{\varnothing}\\
|
|
149 |
\smath{\mathbb{L}([])} & \smath{=} & \smath{\{[]\}}\\
|
|
150 |
\smath{\mathbb{L}(c)} & \smath{=} & \smath{\{[c]\}}\\
|
|
151 |
\smath{\mathbb{L}(r_1 + r_2)} & \smath{=} & \smath{\mathbb{L}(r_1) \cup \mathbb{L}(r_2)}\\
|
|
152 |
\smath{\mathbb{L}(r_1 \cdot r_2)} & \smath{=} & \smath{\mathbb{L}(r_1)\; ;\; \mathbb{L} (r_2)}\\
|
|
153 |
\smath{\mathbb{L}(r^\star)} & \smath{=} & \smath{\mathbb{L}(r)^\star}
|
|
154 |
\end{tabular}
|
|
155 |
\end{center}
|
|
156 |
|
|
157 |
\small
|
|
158 |
\begin{center}
|
|
159 |
\begin{tabular}{rcl}
|
|
160 |
\smath{L_1 ; L_2} & \smath{\dn} & \smath{\{ s_1 @ s_2 \mid s_1 \in L_1 \wedge s_2 \in L_2\}}\bigskip\\
|
|
161 |
\multicolumn{3}{c}{
|
|
162 |
\smath{\infer{[] \in L^\star}{}} \hspace{10mm}
|
|
163 |
\smath{\infer{s_1 @ s_2 \in L^\star}{s_1 \in L & s_2 \in L^\star}}
|
|
164 |
}
|
|
165 |
\end{tabular}
|
|
166 |
\end{center}
|
|
167 |
|
|
168 |
\end{frame}}
|
|
169 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
170 |
|
|
171 |
*}
|
|
172 |
|
|
173 |
text_raw {*
|
|
174 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
175 |
\mode<presentation>{
|
|
176 |
\begin{frame}[c]
|
|
177 |
\frametitle{\LARGE Regular Expression Matching}
|
|
178 |
|
|
179 |
\begin{itemize}
|
|
180 |
\item Harper in JFP'99: ``Functional Pearl: Proof- Directed Debugging''\medskip
|
|
181 |
\item Yi in JFP'06: ``Educational Pearl: `Proof-Directed Debugging' revisited
|
|
182 |
for a first-order version''\medskip
|
|
183 |
\item Owens et al in JFP'09: ``Regular-expression derivatives re-examined''\bigskip\pause
|
|
184 |
|
|
185 |
\begin{quote}\small
|
|
186 |
``Unfortunately, regular expression derivatives have been lost in the
|
|
187 |
sands of time, and few computer scientists are aware of them.''
|
|
188 |
\end{quote}
|
|
189 |
\end{itemize}
|
|
190 |
|
|
191 |
|
|
192 |
\end{frame}}
|
|
193 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
194 |
|
|
195 |
*}
|
|
196 |
|
|
197 |
text_raw {*
|
|
198 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
199 |
\mode<presentation>{
|
|
200 |
\begin{frame}[c]
|
|
201 |
|
|
202 |
\begin{center}
|
|
203 |
\huge\bf Demo
|
|
204 |
\end{center}
|
|
205 |
|
|
206 |
|
|
207 |
\end{frame}}
|
|
208 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
209 |
|
|
210 |
*}
|
|
211 |
|
|
212 |
text_raw {*
|
|
213 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
214 |
\mode<presentation>{
|
|
215 |
\begin{frame}[c]
|
|
216 |
\frametitle{\LARGE The Myhill-Nerode Theorem}
|
|
217 |
|
|
218 |
\begin{itemize}
|
24
|
219 |
\item provides necessary and suf\!ficient conditions for a language
|
|
220 |
being regular (pumping lemma only necessary)\medskip
|
21
|
221 |
|
24
|
222 |
\item will help with closure properties of regular languages\bigskip\pause
|
|
223 |
|
|
224 |
\item key is the equivalence relation:\smallskip
|
21
|
225 |
\begin{center}
|
|
226 |
\smath{x \approx_{L} y \,\dn\, \forall z.\; x @ z \in L \Leftrightarrow y @ z \in L}
|
|
227 |
\end{center}
|
|
228 |
\end{itemize}
|
|
229 |
|
|
230 |
\end{frame}}
|
|
231 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
232 |
|
|
233 |
*}
|
|
234 |
|
|
235 |
text_raw {*
|
|
236 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
237 |
\mode<presentation>{
|
|
238 |
\begin{frame}[c]
|
|
239 |
\frametitle{\LARGE The Myhill-Nerode Theorem}
|
|
240 |
|
212
|
241 |
|
|
242 |
\begin{tikzpicture}[scale=3]
|
|
243 |
\clip[draw] (0.5,0.5) circle (.6cm);
|
|
244 |
\draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
|
|
245 |
\draw (-1.5,0) -- (1.5,0);
|
|
246 |
\draw (0,-1.5) -- (0,1.5);
|
|
247 |
\draw (0,0) circle (1cm);
|
|
248 |
\draw (3mm,0mm) arc (0:30:3mm);
|
|
249 |
\end{tikzpicture}
|
|
250 |
|
|
251 |
|
21
|
252 |
|
|
253 |
\begin{itemize}
|
212
|
254 |
\item \smath{\text{finite}\, (U\!N\!IV /\!/ \approx_L)
|
|
255 |
\;\Leftrightarrow\; L\; \text{is regular}}
|
21
|
256 |
\end{itemize}
|
|
257 |
|
|
258 |
\end{frame}}
|
|
259 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
260 |
|
|
261 |
*}
|
|
262 |
|
|
263 |
|
|
264 |
text_raw {*
|
|
265 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
266 |
\mode<presentation>{
|
|
267 |
\begin{frame}[c]
|
|
268 |
\frametitle{\LARGE Equivalence Classes}
|
|
269 |
|
|
270 |
\begin{itemize}
|
|
271 |
\item \smath{L = []}
|
|
272 |
\begin{center}
|
|
273 |
\smath{\Big\{\{[]\},\; U\!N\!IV - \{[]\}\Big\}}
|
|
274 |
\end{center}\bigskip\bigskip
|
|
275 |
|
|
276 |
\item \smath{L = [c]}
|
|
277 |
\begin{center}
|
|
278 |
\smath{\Big\{\{[]\},\; \{[c]\},\; U\!N\!IV - \{[], [c]\}\Big\}}
|
|
279 |
\end{center}\bigskip\bigskip
|
|
280 |
|
|
281 |
\item \smath{L = \varnothing}
|
|
282 |
\begin{center}
|
|
283 |
\smath{\Big\{U\!N\!IV\Big\}}
|
|
284 |
\end{center}
|
|
285 |
|
|
286 |
\end{itemize}
|
|
287 |
|
|
288 |
\end{frame}}
|
|
289 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
290 |
|
|
291 |
*}
|
|
292 |
|
|
293 |
|
|
294 |
text_raw {*
|
|
295 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
296 |
\mode<presentation>{
|
|
297 |
\begin{frame}[c]
|
|
298 |
\frametitle{\LARGE Regular Languages}
|
|
299 |
|
|
300 |
\begin{itemize}
|
|
301 |
\item \smath{L} is regular \smath{\dn} if there is an automaton \smath{M}
|
|
302 |
such that \smath{\mathbb{L}(M) = L}\\[1.5cm]
|
|
303 |
|
|
304 |
\item Myhill-Nerode:
|
|
305 |
|
|
306 |
\begin{center}
|
|
307 |
\begin{tabular}{l}
|
|
308 |
finite $\Rightarrow$ regular\\
|
|
309 |
\;\;\;\smath{\text{finite}\,(U\!N\!IV /\!/ \approx_L) \Rightarrow \exists r. L = \mathbb{L}(r)}\\[3mm]
|
|
310 |
regular $\Rightarrow$ finite\\
|
|
311 |
\;\;\;\smath{\text{finite}\, (U\!N\!IV /\!/ \approx_{\mathbb{L}(r)})}
|
|
312 |
\end{tabular}
|
|
313 |
\end{center}
|
|
314 |
|
|
315 |
\end{itemize}
|
|
316 |
|
16
|
317 |
\end{frame}}
|
|
318 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
319 |
|
|
320 |
*}
|
|
321 |
|
|
322 |
|
21
|
323 |
text_raw {*
|
|
324 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
325 |
\mode<presentation>{
|
|
326 |
\begin{frame}[c]
|
|
327 |
\frametitle{\LARGE Final States}
|
|
328 |
|
|
329 |
\mbox{}\\[3cm]
|
|
330 |
|
|
331 |
\begin{itemize}
|
|
332 |
\item \smath{\text{final}_L\,X \dn}\\
|
|
333 |
\smath{\hspace{6mm}X \in (U\!N\!IV /\!/\approx_L) \;\wedge\; \forall s \in X.\; s \in L}
|
|
334 |
\smallskip
|
|
335 |
\item we can prove: \smath{L = \bigcup \{X.\;\text{final}_L\,X\}}
|
|
336 |
|
|
337 |
\end{itemize}
|
|
338 |
|
|
339 |
\end{frame}}
|
|
340 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
341 |
*}
|
|
342 |
|
|
343 |
|
|
344 |
text_raw {*
|
|
345 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
346 |
\mode<presentation>{
|
|
347 |
\begin{frame}[c]
|
|
348 |
\frametitle{\LARGE Transitions between\\[-3mm] Equivalence Classes}
|
|
349 |
|
|
350 |
\smath{L = \{[c]\}}
|
|
351 |
|
|
352 |
\begin{tabular}{@ {\hspace{-7mm}}cc}
|
|
353 |
\begin{tabular}{c}
|
|
354 |
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,auto, ultra thick]
|
|
355 |
\tikzstyle{state}=[circle,thick,draw=blue!75,fill=blue!20,minimum size=0mm]
|
|
356 |
|
|
357 |
%\draw[help lines] (0,0) grid (3,2);
|
|
358 |
|
|
359 |
\node[state,initial] (q_0) {$R_1$};
|
|
360 |
\node[state,accepting] (q_1) [above right of=q_0] {$R_2$};
|
|
361 |
\node[state] (q_2) [below right of=q_0] {$R_3$};
|
|
362 |
|
|
363 |
\path[->] (q_0) edge node {c} (q_1)
|
|
364 |
edge node [swap] {$\Sigma-{c}$} (q_2)
|
24
|
365 |
(q_2) edge [loop below] node {$\Sigma$} ()
|
|
366 |
(q_1) edge node {$\Sigma$} (q_2);
|
21
|
367 |
\end{tikzpicture}
|
|
368 |
\end{tabular}
|
|
369 |
&
|
|
370 |
\begin{tabular}[t]{ll}
|
|
371 |
\\[-20mm]
|
|
372 |
\multicolumn{2}{l}{\smath{U\!N\!IV /\!/\approx_L} produces}\\[4mm]
|
|
373 |
|
|
374 |
\smath{R_1}: & \smath{\{[]\}}\\
|
|
375 |
\smath{R_2}: & \smath{\{[c]\}}\\
|
|
376 |
\smath{R_3}: & \smath{U\!N\!IV - \{[], [c]\}}\\[6mm]
|
|
377 |
\multicolumn{2}{l}{\onslide<2->{\smath{X \stackrel{c}{\longrightarrow} Y \dn X ; [c] \subseteq Y}}}
|
|
378 |
\end{tabular}
|
|
379 |
|
|
380 |
\end{tabular}
|
|
381 |
|
|
382 |
\end{frame}}
|
|
383 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
384 |
*}
|
|
385 |
|
|
386 |
|
|
387 |
text_raw {*
|
|
388 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
389 |
\mode<presentation>{
|
|
390 |
\begin{frame}[c]
|
|
391 |
\frametitle{\LARGE Systems of Equations}
|
|
392 |
|
|
393 |
Inspired by a method of Brzozowski\;'64, we can build an equational system
|
|
394 |
characterising the equivalence classes:
|
|
395 |
|
|
396 |
\begin{center}
|
|
397 |
\begin{tabular}{@ {\hspace{-20mm}}c}
|
|
398 |
\\[-13mm]
|
|
399 |
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,auto, ultra thick]
|
|
400 |
\tikzstyle{state}=[circle,thick,draw=blue!75,fill=blue!20,minimum size=0mm]
|
|
401 |
|
|
402 |
%\draw[help lines] (0,0) grid (3,2);
|
|
403 |
|
|
404 |
\node[state,initial] (p_0) {$R_1$};
|
|
405 |
\node[state,accepting] (p_1) [right of=q_0] {$R_2$};
|
|
406 |
|
|
407 |
\path[->] (p_0) edge [bend left] node {a} (p_1)
|
|
408 |
edge [loop above] node {b} ()
|
|
409 |
(p_1) edge [loop above] node {a} ()
|
|
410 |
edge [bend left] node {b} (p_0);
|
|
411 |
\end{tikzpicture}\\
|
|
412 |
\\[-13mm]
|
|
413 |
\end{tabular}
|
|
414 |
\end{center}
|
|
415 |
|
|
416 |
\begin{center}
|
|
417 |
\begin{tabular}{@ {\hspace{-6mm}}ll@ {\hspace{1mm}}c@ {\hspace{1mm}}l}
|
|
418 |
& \smath{R_1} & \smath{\equiv} & \smath{R_1;b + R_2;b \onslide<2->{\alert<2>{+ \lambda;[]}}}\\
|
|
419 |
& \smath{R_2} & \smath{\equiv} & \smath{R_1;a + R_2;a}\medskip\\
|
|
420 |
\onslide<3->{we can prove}
|
|
421 |
& \onslide<3->{\smath{R_1}} & \onslide<3->{\smath{=}}
|
|
422 |
& \onslide<3->{\smath{R_1; \mathbb{L}(b) \,\cup\, R_2;\mathbb{L}(b) \,\cup\, \{[]\};\{[]\}}}\\
|
|
423 |
& \onslide<3->{\smath{R_2}} & \onslide<3->{\smath{=}}
|
|
424 |
& \onslide<3->{\smath{R_1; \mathbb{L}(a) \,\cup\, R_2;\mathbb{L}(a)}}\\
|
|
425 |
\end{tabular}
|
|
426 |
\end{center}
|
|
427 |
|
|
428 |
\end{frame}}
|
|
429 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
430 |
*}
|
|
431 |
|
|
432 |
text_raw {*
|
|
433 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
434 |
\mode<presentation>{
|
|
435 |
\begin{frame}<1>[t]
|
|
436 |
\small
|
|
437 |
|
|
438 |
\begin{center}
|
|
439 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}ll}
|
|
440 |
\onslide<1->{\smath{R_1}} & \onslide<1->{\smath{=}}
|
|
441 |
& \onslide<1->{\smath{R_1; b + R_2; b + \lambda;[]}}\\
|
|
442 |
\onslide<1->{\smath{R_2}} & \onslide<1->{\smath{=}}
|
|
443 |
& \onslide<1->{\smath{R_1; a + R_2; a}}\\
|
|
444 |
|
|
445 |
& & & \onslide<2->{by Arden}\\
|
|
446 |
|
|
447 |
\onslide<2->{\smath{R_1}} & \onslide<2->{\smath{=}}
|
|
448 |
& \onslide<2->{\smath{R_1; b + R_2; b + \lambda;[]}}\\
|
|
449 |
\onslide<2->{\smath{R_2}} & \onslide<2->{\smath{=}}
|
|
450 |
& \only<2>{\smath{R_1; a + R_2; a}}%
|
|
451 |
\only<3->{\smath{R_1; a\cdot a^\star}}\\
|
|
452 |
|
24
|
453 |
& & & \onslide<4->{by Arden}\\
|
21
|
454 |
|
|
455 |
\onslide<4->{\smath{R_1}} & \onslide<4->{\smath{=}}
|
24
|
456 |
& \onslide<4->{\smath{R_2; b \cdot b^\star+ \lambda;b^\star}}\\
|
21
|
457 |
\onslide<4->{\smath{R_2}} & \onslide<4->{\smath{=}}
|
|
458 |
& \onslide<4->{\smath{R_1; a\cdot a^\star}}\\
|
|
459 |
|
24
|
460 |
& & & \onslide<5->{by substitution}\\
|
21
|
461 |
|
|
462 |
\onslide<5->{\smath{R_1}} & \onslide<5->{\smath{=}}
|
24
|
463 |
& \onslide<5->{\smath{R_1; a\cdot a^\star \cdot b \cdot b^\star+ \lambda;b^\star}}\\
|
21
|
464 |
\onslide<5->{\smath{R_2}} & \onslide<5->{\smath{=}}
|
|
465 |
& \onslide<5->{\smath{R_1; a\cdot a^\star}}\\
|
|
466 |
|
24
|
467 |
& & & \onslide<6->{by Arden}\\
|
21
|
468 |
|
|
469 |
\onslide<6->{\smath{R_1}} & \onslide<6->{\smath{=}}
|
|
470 |
& \onslide<6->{\smath{\lambda;b^\star\cdot (a\cdot a^\star \cdot b \cdot b^\star)^\star}}\\
|
|
471 |
\onslide<6->{\smath{R_2}} & \onslide<6->{\smath{=}}
|
24
|
472 |
& \onslide<6->{\smath{R_1; a\cdot a^\star}}\\
|
|
473 |
|
|
474 |
& & & \onslide<7->{by substitution}\\
|
|
475 |
|
|
476 |
\onslide<7->{\smath{R_1}} & \onslide<7->{\smath{=}}
|
|
477 |
& \onslide<7->{\smath{\lambda;b^\star\cdot (a\cdot a^\star \cdot b \cdot b^\star)^\star}}\\
|
|
478 |
\onslide<7->{\smath{R_2}} & \onslide<7->{\smath{=}}
|
|
479 |
& \onslide<7->{\smath{\lambda; b^\star\cdot (a\cdot a^\star \cdot b \cdot b^\star)^\star
|
21
|
480 |
\cdot a\cdot a^\star}}\\
|
|
481 |
\end{tabular}
|
|
482 |
\end{center}
|
|
483 |
|
|
484 |
\end{frame}}
|
|
485 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
486 |
*}
|
|
487 |
|
|
488 |
text_raw {*
|
|
489 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
490 |
\mode<presentation>{
|
|
491 |
\begin{frame}[c]
|
|
492 |
\frametitle{\LARGE A Variant of Arden's Lemma}
|
|
493 |
|
24
|
494 |
{\bf Arden's Lemma:}\smallskip
|
21
|
495 |
|
|
496 |
If \smath{[] \not\in A} then
|
|
497 |
\begin{center}
|
|
498 |
\smath{X = X; A + \text{something}}
|
|
499 |
\end{center}
|
|
500 |
has the (unique) solution
|
|
501 |
\begin{center}
|
|
502 |
\smath{X = \text{something} ; A^\star}
|
|
503 |
\end{center}
|
|
504 |
|
|
505 |
|
|
506 |
\end{frame}}
|
|
507 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
508 |
*}
|
|
509 |
|
|
510 |
|
|
511 |
text_raw {*
|
|
512 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
513 |
\mode<presentation>{
|
|
514 |
\begin{frame}<1->[t]
|
|
515 |
\small
|
|
516 |
|
|
517 |
\begin{center}
|
|
518 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}ll}
|
|
519 |
\onslide<1->{\smath{R_1}} & \onslide<1->{\smath{=}}
|
|
520 |
& \onslide<1->{\smath{R_1; b + R_2; b + \lambda;[]}}\\
|
|
521 |
\onslide<1->{\smath{R_2}} & \onslide<1->{\smath{=}}
|
|
522 |
& \onslide<1->{\smath{R_1; a + R_2; a}}\\
|
|
523 |
|
|
524 |
& & & \onslide<2->{by Arden}\\
|
|
525 |
|
|
526 |
\onslide<2->{\smath{R_1}} & \onslide<2->{\smath{=}}
|
|
527 |
& \onslide<2->{\smath{R_1; b + R_2; b + \lambda;[]}}\\
|
|
528 |
\onslide<2->{\smath{R_2}} & \onslide<2->{\smath{=}}
|
|
529 |
& \only<2>{\smath{R_1; a + R_2; a}}%
|
|
530 |
\only<3->{\smath{R_1; a\cdot a^\star}}\\
|
|
531 |
|
24
|
532 |
& & & \onslide<4->{by Arden}\\
|
21
|
533 |
|
|
534 |
\onslide<4->{\smath{R_1}} & \onslide<4->{\smath{=}}
|
24
|
535 |
& \onslide<4->{\smath{R_2; b \cdot b^\star+ \lambda;b^\star}}\\
|
21
|
536 |
\onslide<4->{\smath{R_2}} & \onslide<4->{\smath{=}}
|
|
537 |
& \onslide<4->{\smath{R_1; a\cdot a^\star}}\\
|
|
538 |
|
24
|
539 |
& & & \onslide<5->{by substitution}\\
|
21
|
540 |
|
|
541 |
\onslide<5->{\smath{R_1}} & \onslide<5->{\smath{=}}
|
24
|
542 |
& \onslide<5->{\smath{R_1; a\cdot a^\star \cdot b \cdot b^\star+ \lambda;b^\star}}\\
|
21
|
543 |
\onslide<5->{\smath{R_2}} & \onslide<5->{\smath{=}}
|
|
544 |
& \onslide<5->{\smath{R_1; a\cdot a^\star}}\\
|
|
545 |
|
24
|
546 |
& & & \onslide<6->{by Arden}\\
|
21
|
547 |
|
|
548 |
\onslide<6->{\smath{R_1}} & \onslide<6->{\smath{=}}
|
|
549 |
& \onslide<6->{\smath{\lambda;b^\star\cdot (a\cdot a^\star \cdot b \cdot b^\star)^\star}}\\
|
|
550 |
\onslide<6->{\smath{R_2}} & \onslide<6->{\smath{=}}
|
24
|
551 |
& \onslide<6->{\smath{R_1; a\cdot a^\star}}\\
|
|
552 |
|
|
553 |
& & & \onslide<7->{by substitution}\\
|
|
554 |
|
|
555 |
\onslide<7->{\smath{R_1}} & \onslide<7->{\smath{=}}
|
|
556 |
& \onslide<7->{\smath{\lambda;b^\star\cdot (a\cdot a^\star \cdot b \cdot b^\star)^\star}}\\
|
|
557 |
\onslide<7->{\smath{R_2}} & \onslide<7->{\smath{=}}
|
|
558 |
& \onslide<7->{\smath{\lambda; b^\star\cdot (a\cdot a^\star \cdot b \cdot b^\star)^\star
|
21
|
559 |
\cdot a\cdot a^\star}}\\
|
|
560 |
\end{tabular}
|
|
561 |
\end{center}
|
|
562 |
|
|
563 |
\only<8->{
|
|
564 |
\begin{textblock}{6}(2.5,4)
|
|
565 |
\begin{block}{}
|
|
566 |
\begin{minipage}{8cm}\raggedright
|
|
567 |
|
|
568 |
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,auto, ultra thick, inner sep=1mm]
|
|
569 |
\tikzstyle{state}=[circle,thick,draw=blue!75,fill=blue!20,minimum size=0mm]
|
|
570 |
|
|
571 |
%\draw[help lines] (0,0) grid (3,2);
|
|
572 |
|
|
573 |
\node[state,initial] (p_0) {$R_1$};
|
|
574 |
\node[state,accepting] (p_1) [right of=q_0] {$R_2$};
|
|
575 |
|
|
576 |
\path[->] (p_0) edge [bend left] node {a} (p_1)
|
|
577 |
edge [loop above] node {b} ()
|
|
578 |
(p_1) edge [loop above] node {a} ()
|
|
579 |
edge [bend left] node {b} (p_0);
|
|
580 |
\end{tikzpicture}
|
|
581 |
|
|
582 |
\end{minipage}
|
|
583 |
\end{block}
|
|
584 |
\end{textblock}}
|
|
585 |
|
|
586 |
\end{frame}}
|
|
587 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
588 |
*}
|
|
589 |
|
|
590 |
text_raw {*
|
|
591 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
592 |
\mode<presentation>{
|
|
593 |
\begin{frame}[c]
|
|
594 |
\frametitle{\LARGE The Equ's Solving Algorithm}
|
|
595 |
|
|
596 |
\begin{itemize}
|
|
597 |
\item The algorithm must terminate: Arden makes one equation smaller;
|
|
598 |
substitution deletes one variable from the right-hand sides.\bigskip
|
|
599 |
|
24
|
600 |
\item We need to maintain the invariant that Arden is applicable
|
|
601 |
(if \smath{[] \not\in A} then \ldots):\medskip
|
|
602 |
|
|
603 |
\begin{center}\small
|
|
604 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}ll}
|
|
605 |
\smath{R_1} & \smath{=} & \smath{R_1; b + R_2; b + \lambda;[]}\\
|
|
606 |
\smath{R_2} & \smath{=} & \smath{R_1; a + R_2; a}\\
|
|
607 |
|
|
608 |
& & & by Arden\\
|
|
609 |
|
|
610 |
\smath{R_1} & \smath{=} & \smath{R_1; b + R_2; b + \lambda;[]}\\
|
|
611 |
\smath{R_2} & \smath{=} & \smath{R_1; a\cdot a^\star}\\
|
|
612 |
\end{tabular}
|
|
613 |
\end{center}
|
|
614 |
|
|
615 |
\end{itemize}
|
|
616 |
|
|
617 |
|
|
618 |
\end{frame}}
|
|
619 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
620 |
*}
|
|
621 |
|
|
622 |
text_raw {*
|
|
623 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
624 |
\mode<presentation>{
|
|
625 |
\begin{frame}[c]
|
|
626 |
\frametitle{\LARGE The Equ's Solving Algorithm}
|
|
627 |
|
|
628 |
\begin{itemize}
|
|
629 |
\item The algorithm is still a bit hairy to formalise because of our set-representation
|
21
|
630 |
for equations:
|
|
631 |
|
|
632 |
\begin{center}
|
|
633 |
\begin{tabular}{ll}
|
|
634 |
\smath{\big\{ (X, \{(Y_1, r_1), (Y_2, r_2), \ldots\}),}\\
|
|
635 |
\mbox{}\hspace{5mm}\smath{\ldots}\\
|
|
636 |
& \smath{\big\}}
|
|
637 |
\end{tabular}
|
24
|
638 |
\end{center}\bigskip\pause
|
21
|
639 |
|
|
640 |
\small
|
24
|
641 |
they are generated from \smath{U\!N\!IV /\!/ \approx_L}
|
21
|
642 |
|
|
643 |
\end{itemize}
|
|
644 |
|
|
645 |
|
|
646 |
\end{frame}}
|
|
647 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
648 |
*}
|
|
649 |
|
24
|
650 |
|
|
651 |
|
21
|
652 |
text_raw {*
|
|
653 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
654 |
\mode<presentation>{
|
|
655 |
\begin{frame}[c]
|
|
656 |
\frametitle{\LARGE Other Direction}
|
|
657 |
|
|
658 |
One has to prove
|
|
659 |
|
|
660 |
\begin{center}
|
|
661 |
\smath{\text{finite} (U\!N\!IV /\!/ \approx_{\mathbb{L}(r)})}
|
|
662 |
\end{center}
|
|
663 |
|
|
664 |
by induction on \smath{r}. Not trivial, but after a bit
|
|
665 |
of thinking (by Chunhan), one can prove that if
|
|
666 |
|
|
667 |
\begin{center}
|
|
668 |
\smath{\text{finite} (U\!N\!IV /\!/ \approx_{\mathbb{L}(r_1)})}\hspace{5mm}
|
|
669 |
\smath{\text{finite} (U\!N\!IV /\!/ \approx_{\mathbb{L}(r_2)})}
|
|
670 |
\end{center}
|
|
671 |
|
|
672 |
then
|
|
673 |
|
|
674 |
\begin{center}
|
|
675 |
\smath{\text{finite} (U\!N\!IV /\!/ \approx_{\mathbb{L}(r_1) \,\cup\, \mathbb{L}(r_2)})}
|
|
676 |
\end{center}
|
|
677 |
|
|
678 |
|
|
679 |
|
|
680 |
\end{frame}}
|
|
681 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
682 |
*}
|
|
683 |
|
|
684 |
text_raw {*
|
|
685 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
686 |
\mode<presentation>{
|
|
687 |
\begin{frame}[c]
|
|
688 |
\frametitle{\LARGE What Have We Achieved?}
|
|
689 |
|
|
690 |
\begin{itemize}
|
|
691 |
\item \smath{\text{finite}\, (U\!N\!IV /\!/ \approx_L) \;\Leftrightarrow\; L\; \text{is regular}}
|
|
692 |
\bigskip\pause
|
24
|
693 |
\item regular languages are closed under complementation; this is easy
|
21
|
694 |
\begin{center}
|
|
695 |
\smath{U\!N\!IV /\!/ \approx_L \;\;=\;\; U\!N\!IV /\!/ \approx_{-L}}
|
|
696 |
\end{center}\pause\bigskip
|
|
697 |
|
24
|
698 |
\item if you want to do regular expression matching (see Scott's paper)\pause\bigskip
|
21
|
699 |
|
24
|
700 |
\item I cannot yet give definite numbers
|
21
|
701 |
\end{itemize}
|
|
702 |
|
|
703 |
\only<2>{
|
|
704 |
\begin{textblock}{10}(4,14)
|
|
705 |
\small
|
|
706 |
\smath{x \approx_{L} y \,\dn\, \forall z.\; x @ z \in L \Leftrightarrow y @ z \in L}
|
|
707 |
\end{textblock}
|
|
708 |
}
|
|
709 |
|
24
|
710 |
|
|
711 |
|
21
|
712 |
\end{frame}}
|
|
713 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
714 |
*}
|
|
715 |
|
|
716 |
text_raw {*
|
|
717 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
718 |
\mode<presentation>{
|
|
719 |
\begin{frame}[c]
|
24
|
720 |
\frametitle{\LARGE Examples}
|
|
721 |
|
|
722 |
\begin{itemize}
|
|
723 |
\item \smath{L \equiv \Sigma^\star 0 \Sigma} is regular
|
|
724 |
\begin{quote}\small
|
|
725 |
\begin{tabular}{lcl}
|
|
726 |
\smath{A_1} & \smath{=} & \smath{\Sigma^\star 00}\\
|
|
727 |
\smath{A_2} & \smath{=} & \smath{\Sigma^\star 01}\\
|
|
728 |
\smath{A_3} & \smath{=} & \smath{\Sigma^\star 10 \cup \{0\}}\\
|
|
729 |
\smath{A_4} & \smath{=} & \smath{\Sigma^\star 11 \cup \{1\} \cup \{[]\}}\\
|
|
730 |
\end{tabular}
|
|
731 |
\end{quote}
|
|
732 |
|
|
733 |
\item \smath{L \equiv \{ 0^n 1^n \,|\, n \ge 0\}} is not regular
|
|
734 |
\begin{quote}\small
|
|
735 |
\begin{tabular}{lcl}
|
|
736 |
\smath{B_0} & \smath{=} & \smath{\{0^n 1^n \,|\, n \ge 0\}}\\
|
|
737 |
\smath{B_1} & \smath{=} & \smath{\{0^n 1^{(n-1)} \,|\, n \ge 1\}}\\
|
|
738 |
\smath{B_2} & \smath{=} & \smath{\{0^n 1^{(n-2)} \,|\, n \ge 2\}}\\
|
|
739 |
\smath{B_3} & \smath{=} & \smath{\{0^n 1^{(n-3)} \,|\, n \ge 3\}}\\
|
|
740 |
& \smath{\vdots} &\\
|
|
741 |
\end{tabular}
|
|
742 |
\end{quote}
|
|
743 |
\end{itemize}
|
|
744 |
|
|
745 |
\end{frame}}
|
|
746 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
747 |
*}
|
|
748 |
|
|
749 |
|
|
750 |
text_raw {*
|
|
751 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
752 |
\mode<presentation>{
|
|
753 |
\begin{frame}[c]
|
|
754 |
\frametitle{\LARGE What We Have Not Achieved}
|
|
755 |
|
|
756 |
\begin{itemize}
|
|
757 |
\item regular expressions are not good if you look for a minimal
|
|
758 |
one for a language (DFAs have this notion)\pause\bigskip
|
|
759 |
|
|
760 |
\item Is there anything to be said about context free languages:\medskip
|
|
761 |
|
|
762 |
\begin{quote}
|
|
763 |
A context free language is where every string can be recognised by
|
|
764 |
a pushdown automaton.
|
|
765 |
\end{quote}
|
|
766 |
\end{itemize}
|
|
767 |
|
|
768 |
\end{frame}}
|
|
769 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
770 |
*}
|
|
771 |
|
|
772 |
|
|
773 |
text_raw {*
|
|
774 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
775 |
\mode<presentation>{
|
|
776 |
\begin{frame}[c]
|
21
|
777 |
\frametitle{\LARGE Conclusion}
|
|
778 |
|
|
779 |
\begin{itemize}
|
24
|
780 |
\item on balance regular expression are superior
|
|
781 |
to DFAs, in my opinion\bigskip
|
21
|
782 |
|
|
783 |
\item I cannot think of a reason to not teach regular languages
|
24
|
784 |
to students this way (!?)\bigskip
|
21
|
785 |
|
|
786 |
\item I have never ever seen a proof of Myhill-Nerode based on
|
|
787 |
regular expressions\bigskip
|
|
788 |
|
24
|
789 |
\item no application, but lots of fun\bigskip
|
21
|
790 |
|
|
791 |
\item great source of examples
|
|
792 |
|
|
793 |
\end{itemize}
|
|
794 |
|
|
795 |
\end{frame}}
|
|
796 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
797 |
*}
|
|
798 |
|
16
|
799 |
(*<*)
|
|
800 |
end
|
|
801 |
(*>*) |