33
|
1 |
\documentclass[dvipsnames,14pt,t]{beamer}
|
142
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
2 |
\usepackage{beamerthemeplaincu}
|
33
|
3 |
\usepackage[absolute,overlay]{textpos}
|
|
4 |
\usepackage{ifthen}
|
|
5 |
\usepackage{tikz}
|
|
6 |
\usepackage{pgf}
|
|
7 |
\usepackage{calc}
|
|
8 |
\usepackage{ulem}
|
|
9 |
\usepackage{courier}
|
|
10 |
\usepackage{listings}
|
|
11 |
\renewcommand{\uline}[1]{#1}
|
|
12 |
\usetikzlibrary{arrows}
|
|
13 |
\usetikzlibrary{automata}
|
|
14 |
\usetikzlibrary{shapes}
|
|
15 |
\usetikzlibrary{shadows}
|
|
16 |
\usetikzlibrary{positioning}
|
|
17 |
\usetikzlibrary{calc}
|
145
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
18 |
\usetikzlibrary{fit}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
19 |
\usetikzlibrary{plotmarks}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
20 |
\usetikzlibrary{backgrounds}
|
33
|
21 |
\usepackage{graphicx}
|
215
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
22 |
\usepackage{../langs}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
23 |
\usepackage{../data}
|
33
|
24 |
|
145
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
25 |
\makeatletter
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
26 |
\lst@CCPutMacro\lst@ProcessOther {"2D}{\lst@ttfamily{-{}}{-{}}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
27 |
\@empty\z@\@empty
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
28 |
\makeatother
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
29 |
|
33
|
30 |
|
142
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
31 |
\renewcommand{\slidecaption}{AFL 04, King's College London, 16.~October 2013}
|
33
|
32 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}}
|
|
33 |
\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions
|
|
34 |
|
|
35 |
\begin{document}
|
|
36 |
|
|
37 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
38 |
\mode<presentation>{
|
|
39 |
\begin{frame}<1>[t]
|
|
40 |
\frametitle{%
|
|
41 |
\begin{tabular}{@ {}c@ {}}
|
|
42 |
\\[-3mm]
|
|
43 |
\LARGE Automata and \\[-2mm]
|
|
44 |
\LARGE Formal Languages (4)\\[3mm]
|
|
45 |
\end{tabular}}
|
|
46 |
|
|
47 |
\normalsize
|
|
48 |
\begin{center}
|
|
49 |
\begin{tabular}{ll}
|
|
50 |
Email: & christian.urban at kcl.ac.uk\\
|
142
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
51 |
Office: & S1.27 (1st floor Strand Building)\\
|
33
|
52 |
Slides: & KEATS (also home work is there)\\
|
|
53 |
\end{tabular}
|
|
54 |
\end{center}
|
|
55 |
|
|
56 |
|
|
57 |
\end{frame}}
|
|
58 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
59 |
|
139
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
60 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
61 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
62 |
\mode<presentation>{
|
144
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
63 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
64 |
\frametitle{Regexps and Automata}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
65 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
66 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
67 |
\begin{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
68 |
\node (rexp) {\bl{\bf Regexps}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
69 |
\node (nfa) [right=of rexp] {\bl{\bf NFAs}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
70 |
\node (dfa) [right=of nfa] {\bl{\bf DFAs}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
71 |
\onslide<3->{\node (mdfa) [right=of dfa] {\bl{\bf \begin{tabular}{c}minimal\\ DFAs\end{tabular}}};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
72 |
\path[->, red, line width=2mm] (rexp) edge node [above=4mm, black] {\begin{tabular}{c@{\hspace{9mm}}}Thompson's\\[-1mm] construction\end{tabular}} (nfa);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
73 |
\path[->, red, line width=2mm] (nfa) edge node [above=4mm, black] {\begin{tabular}{c}subset\\[-1mm] construction\end{tabular}}(dfa);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
74 |
\onslide<3->{\path[->, red, line width=2mm] (dfa) edge node [below=9mm, black] {minimisation} (mdfa);}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
75 |
\onslide<2->{\path[->, red, line width=2mm] (dfa) edge [bend left=45] (rexp);}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
76 |
\end{tikzpicture}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
77 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
78 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
79 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
80 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
81 |
|
145
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
82 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
83 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
84 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
85 |
\frametitle{\begin{tabular}{c}DFAs\end{tabular}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
86 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
87 |
A deterministic finite automaton consists of:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
88 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
89 |
\begin{itemize}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
90 |
\item a finite set of states, \bl{$Q$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
91 |
\item one of these states is the start state, \bl{$q_0$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
92 |
\item there is transition function, \bl{$\delta$}, and
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
93 |
\item some states are accepting states, \bl{$F$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
94 |
\medskip
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
95 |
\end{itemize}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
96 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
97 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
98 |
\bl{$A(Q, q_0, \delta, F)$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
99 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
100 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
101 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
102 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
103 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
104 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
105 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
106 |
\frametitle{\begin{tabular}{c}State Nodes\end{tabular}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
107 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
108 |
\hspace{5mm}\mbox{{\lstset{language=Scala}\consolas\fontsize{9}{10}\selectfont
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
109 |
\lstinputlisting{../progs/appA.scala}}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
110 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
111 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
112 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
113 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
114 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
115 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
116 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
117 |
\frametitle{\begin{tabular}{c}DFAs\;\;\;\end{tabular}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
118 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
119 |
\mbox{}\\[7mm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
120 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
121 |
\mbox{{\lstset{language=Scala}\consolas\fontsize{9}{10}\selectfont
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
122 |
\lstinputlisting{../progs/appB.scala}}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
123 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
124 |
\only<2->{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
125 |
\begin{textblock}{9}(7.5,0.5)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
126 |
\begin{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
127 |
\draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
128 |
{\normalsize\color{darkgray}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
129 |
\begin{minipage}{6cm}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
130 |
\begin{tabular}{l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
131 |
\bl{$\hat{\delta}(q, \texttt{""}) \dn q$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
132 |
\bl{$\hat{\delta}(q, c::s) \dn \hat{\delta}(\delta(q, c), s)$}\\[4mm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
133 |
\bl{$\hat{\delta}(q_0, s) \in F$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
134 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
135 |
\end{minipage}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
136 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
137 |
\end{textblock}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
138 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
139 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
140 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
141 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
142 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
143 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
144 |
\begin{frame}[t]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
145 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
146 |
\mbox{}\hspace{-10mm}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
147 |
\begin{tikzpicture}[scale=0.6,>=stealth',very thick,auto,
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
148 |
every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
149 |
\node[state,initial] (q_0) {$q_0$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
150 |
\node[state] (q_1) [right=of q_0] {$q_1$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
151 |
\node[state] (q_2) [below right=of q_0] {$q_2$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
152 |
\node[state] (q_3) [right=of q_2] {$q_3$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
153 |
\node[state, accepting] (q_4) [right=of q_1] {$q_4$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
154 |
\path[->] (q_0) edge node [above] {\alert{$a$}} (q_1);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
155 |
\path[->] (q_1) edge node [above] {\alert{$a$}} (q_4);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
156 |
\path[->] (q_4) edge [loop right] node {\alert{$a, b$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
157 |
\path[->] (q_3) edge node [right] {\alert{$a$}} (q_4);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
158 |
\path[->] (q_2) edge node [above] {\alert{$a$}} (q_3);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
159 |
\path[->] (q_1) edge node [right] {\alert{$b$}} (q_2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
160 |
\path[->] (q_0) edge node [above] {\alert{$b$}} (q_2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
161 |
\path[->] (q_2) edge [loop left] node {\alert{$b$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
162 |
\path[->] (q_3) edge [bend left=95, looseness=1.3] node [below] {\alert{$b$}} (q_0);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
163 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
164 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
165 |
\only<1->{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
166 |
\begin{textblock}{9}(7.4,3.5)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
167 |
\begin{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
168 |
\draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
169 |
{\normalsize\color{darkgray}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
170 |
\begin{minipage}{6.6cm}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
171 |
\hspace{5mm}\mbox{{\lstset{language=Scala}\consolas\fontsize{8}{10}\selectfont
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
172 |
\lstinputlisting{../progs/appC.scala}}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
173 |
\end{minipage}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
174 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
175 |
\end{textblock}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
176 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
177 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
178 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
179 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
180 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
181 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
182 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
183 |
\frametitle{\begin{tabular}{c}NFAs\end{tabular}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
184 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
185 |
A non-deterministic finite automaton \bl{$A(Q, q_0, \delta, F)$} consists of:\medskip
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
186 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
187 |
\begin{itemize}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
188 |
\item a finite set of states, \bl{$Q$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
189 |
\item one of these states is the start state, \bl{$q_0$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
190 |
\item some states are accepting states, \bl{$F$},
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
191 |
\item there is transition \alert{relation}, \bl{$\delta$}, and
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
192 |
\item there are \alert{silent} transitions\medskip
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
193 |
\end{itemize}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
194 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
195 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
196 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
197 |
\begin{tabular}{c}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
198 |
\bl{$(q_1, a) \rightarrow q_2$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
199 |
\bl{$(q_1, a) \rightarrow q_3$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
200 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
201 |
\hspace{10mm}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
202 |
\begin{tabular}{c}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
203 |
\bl{$(q_1, \epsilon) \rightarrow q_2$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
204 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
205 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
206 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
207 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
208 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
209 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
210 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
211 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
212 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
213 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
214 |
\hspace{5mm}\mbox{{\lstset{language=Scala}\consolas\fontsize{9}{10}\selectfont
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
215 |
\lstinputlisting{../progs/appD.scala}}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
216 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
217 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
218 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
219 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
220 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
221 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
222 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
223 |
\begin{frame}[t]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
224 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
225 |
\mbox{}\hspace{-10mm}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
226 |
\begin{tikzpicture}[scale=0.6,>=stealth',very thick,auto,
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
227 |
every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
228 |
\node[state,initial] (q_0) {$q_0$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
229 |
\node[state] (q_1) [above=of q_0] {$q_1$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
230 |
\node[state, accepting] (q_2) [below=of q_0] {$q_2$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
231 |
\path[->] (q_0) edge node [left] {\alert{$\epsilon$}} (q_1);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
232 |
\path[->] (q_0) edge node [left] {\alert{$\epsilon$}} (q_2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
233 |
\path[->] (q_0) edge [loop right] node {\alert{$a$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
234 |
\path[->] (q_1) edge [loop above] node {\alert{$a$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
235 |
\path[->] (q_2) edge [loop below] node {\alert{$b$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
236 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
237 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
238 |
\only<1->{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
239 |
\begin{textblock}{9}(6,1.5)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
240 |
\begin{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
241 |
\draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
242 |
{\normalsize\color{darkgray}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
243 |
\begin{minipage}{7cm}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
244 |
\hspace{5mm}\mbox{{\lstset{language=Scala}\consolas\fontsize{8}{10}\selectfont
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
245 |
\lstinputlisting{../progs/appE.scala}}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
246 |
\end{minipage}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
247 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
248 |
\end{textblock}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
249 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
250 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
251 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
252 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
253 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
254 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
255 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
256 |
\frametitle{Rexp to NFA}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
257 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
258 |
Thompson's construction of a NFA from a regular expression:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
259 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
260 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
261 |
\begin{tabular}[t]{l@{\hspace{10mm}}l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
262 |
\raisebox{1mm}{\bl{$\varnothing$}} &
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
263 |
\begin{tikzpicture}[scale=0.7,>=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
264 |
\node[state, initial] (q_0) {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
265 |
\end{tikzpicture}\\\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
266 |
\raisebox{1mm}{\bl{$\epsilon$}} &
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
267 |
\begin{tikzpicture}[scale=0.7,>=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
268 |
\node[state, initial, accepting] (q_0) {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
269 |
\end{tikzpicture}\\\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
270 |
\raisebox{2mm}{\bl{$c$}} &
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
271 |
\begin{tikzpicture}[scale=0.7,>=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
272 |
\node[state, initial] (q_0) {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
273 |
\node[state, accepting] (q_1) [right=of q_0] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
274 |
\path[->] (q_0) edge node [below] {\alert{$c$}} (q_1);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
275 |
\end{tikzpicture}\\\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
276 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
277 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
278 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
279 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
280 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
281 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
282 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
283 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
284 |
\begin{frame}[t]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
285 |
\frametitle{Case $r_1\cdot r_2$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
286 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
287 |
\mbox{}\bigskip
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
288 |
\onslide<1>{By recursion we are given two automata:\bigskip}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
289 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
290 |
{\centering\begin{tikzpicture}[node distance=3mm,
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
291 |
>=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
292 |
\node[state, initial] (q_0) {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
293 |
\node (r_1) [right=of q_0] {$\ldots$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
294 |
\only<1>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
295 |
\node[state, accepting] (t_1) [right=of r_1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
296 |
\node[state, accepting] (t_2) [above=of t_1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
297 |
\node[state, accepting] (t_3) [below=of t_1] {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
298 |
\only<2>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
299 |
\node[state] (t_1) [right=of r_1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
300 |
\node[state] (t_2) [above=of t_1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
301 |
\node[state] (t_3) [below=of t_1] {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
302 |
\only<1>{\node[state, initial] (a_0) [right=2.5cm of t_1] {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
303 |
\only<2>{\node[state] (a_0) [right=2.5cm of t_1] {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
304 |
\node (b_1) [right=of a_0] {$\ldots$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
305 |
\node[state, accepting] (c_1) [right=of b_1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
306 |
\node[state, accepting] (c_2) [above=of c_1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
307 |
\node[state, accepting] (c_3) [below=of c_1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
308 |
\only<2>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
309 |
\path[->] (t_1) edge node [above, pos=0.3] {\alert{$\epsilon$}} (a_0);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
310 |
\path[->] (t_2) edge node [above] {\alert{$\epsilon$}} (a_0);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
311 |
\path[->] (t_3) edge node [below] {\alert{$\epsilon$}} (a_0);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
312 |
}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
313 |
\begin{pgfonlayer}{background}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
314 |
\only<1>{\node (1) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (q_0) (r_1) (t_1) (t_2) (t_3)] {};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
315 |
\only<1>{\node (2) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (a_0) (b_1) (c_1) (c_2) (c_3)] {};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
316 |
\only<2>{\node (3) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (q_0) (c_1) (c_2) (c_3)] {};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
317 |
\only<1>{\node [yshift=2mm] at (1.north) {\bl{$r_1$}};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
318 |
\only<1>{\node [yshift=2mm] at (2.north) {\bl{$r_2$}};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
319 |
\only<2>{\node [yshift=2mm] at (3.north) {\bl{$r_1\cdot r_2$}};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
320 |
\end{pgfonlayer}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
321 |
\end{tikzpicture}}\bigskip\bigskip
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
322 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
323 |
\small
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
324 |
We need to (1) change the accepting nodes of the first automaton into non-accepting nodes, and (2) connect them
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
325 |
via $\epsilon$-transitions to the starting state of the second automaton.
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
326 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
327 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
328 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
329 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
330 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
331 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
332 |
\begin{frame}[t]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
333 |
\frametitle{Case $r_1+ r_2$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
334 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
335 |
\onslide<1>{By recursion we are given two automata:\smallskip}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
336 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
337 |
\hspace{2cm}\begin{tikzpicture}[node distance=3mm,
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
338 |
>=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
339 |
\onslide<1>{\node at (0,0) (1) {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
340 |
\onslide<2>{\node at (0,0) [state, initial] (1) {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
341 |
\only<1>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
342 |
\node[state, initial] (2) [above right=16mm of 1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
343 |
\node[state, initial] (3) [below right=16mm of 1] {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
344 |
\only<2>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
345 |
\node[state] (2) [above right=16mm of 1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
346 |
\node[state] (3) [below right=16mm of 1] {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
347 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
348 |
\node (a) [right=of 2] {$\ldots$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
349 |
\node[state, accepting] (a1) [right=of a] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
350 |
\node[state, accepting] (a2) [above=of a1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
351 |
\node[state, accepting] (a3) [below=of a1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
352 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
353 |
\node (b) [right=of 3] {$\ldots$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
354 |
\node[state, accepting] (b1) [right=of b] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
355 |
\node[state, accepting] (b2) [above=of b1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
356 |
\node[state, accepting] (b3) [below=of b1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
357 |
\only<2>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
358 |
\path[->] (1) edge node [above] {\alert{$\epsilon$}} (2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
359 |
\path[->] (1) edge node [below] {\alert{$\epsilon$}} (3);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
360 |
}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
361 |
\begin{pgfonlayer}{background}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
362 |
\only<1>{\node (1) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (2) (a1) (a2) (a3)] {};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
363 |
\only<1>{\node (2) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (3) (b1) (b2) (b3)] {};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
364 |
\only<2>{\node (3) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (1) (a2) (a3) (b2) (b3)] {};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
365 |
\only<1>{\node [yshift=3mm] at (1.north) {\bl{$r_1$}};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
366 |
\only<1>{\node [yshift=3mm] at (2.north) {\bl{$r_2$}};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
367 |
\only<2>{\node [yshift=3mm] at (3.north) {\bl{$r_1+ r_2$}};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
368 |
\end{pgfonlayer}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
369 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
370 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
371 |
\small
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
372 |
We (1) need to introduce a new starting state and (2) connect it to the original two starting states.
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
373 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
374 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
375 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
376 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
377 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
378 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
379 |
\frametitle{Case $r^*$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
380 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
381 |
\onslide<1>{By recursion we are given an automaton for $r$:\smallskip}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
382 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
383 |
\hspace{2cm}\begin{tikzpicture}[node distance=3mm,
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
384 |
>=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
385 |
\onslide<1>{\node at (0,0) (1) {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
386 |
\onslide<2->{\node at (0,0) [state, initial,accepting] (1) {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
387 |
\only<1>{\node[state, initial] (2) [right=16mm of 1] {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
388 |
\only<2->{\node[state] (2) [right=16mm of 1] {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
389 |
\node (a) [right=of 2] {$\ldots$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
390 |
\only<1>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
391 |
\node[state, accepting] (a1) [right=of a] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
392 |
\node[state, accepting] (a2) [above=of a1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
393 |
\node[state, accepting] (a3) [below=of a1] {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
394 |
\only<2->{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
395 |
\node[state] (a1) [right=of a] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
396 |
\node[state] (a2) [above=of a1] {$\mbox{}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
397 |
\node[state] (a3) [below=of a1] {$\mbox{}$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
398 |
\only<2->{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
399 |
\path[->] (1) edge node [above] {\alert{$\epsilon$}} (2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
400 |
\path[->] (a1) edge [bend left=45] node [above] {\alert{$\epsilon$}} (1);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
401 |
\path[->] (a2) edge [bend right] node [below] {\alert{$\epsilon$}} (1);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
402 |
\path[->] (a3) edge [bend left=45] node [below] {\alert{$\epsilon$}} (1);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
403 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
404 |
}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
405 |
\begin{pgfonlayer}{background}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
406 |
\only<1>{\node (1) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (2) (a1) (a2) (a3)] {};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
407 |
\only<2->{\node (2) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (1) (a2) (a3)] {};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
408 |
\only<1>{\node [yshift=3mm] at (1.north) {\bl{$r$}};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
409 |
\only<2->{\node [yshift=3mm] at (2.north) {\bl{$r^*$}};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
410 |
\end{pgfonlayer}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
411 |
\end{tikzpicture}\bigskip
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
412 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
413 |
\onslide<3->{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
414 |
Why can't we just have an epsilon transition from the accepting states to the starting state?}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
415 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
416 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
417 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
418 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
419 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
420 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
421 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
422 |
\begin{frame}[t]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
423 |
\frametitle{\begin{tabular}{c}\bl{$(a?\{n\}) \cdot a\{n\}$}\end{tabular}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
424 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
425 |
\mbox{}\\[-13mm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
426 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
427 |
\begin{tikzpicture}[y=.2cm, x=.09cm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
428 |
%axis
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
429 |
\draw (0,0) -- coordinate (x axis mid) (100,0);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
430 |
\draw (0,0) -- coordinate (y axis mid) (0,30);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
431 |
%ticks
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
432 |
\foreach \x in {0,10,...,100}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
433 |
\draw (\x,1pt) -- (\x,-3pt)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
434 |
node[anchor=north] {\x};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
435 |
\foreach \y in {0,5,...,30}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
436 |
\draw (1pt,\y) -- (-3pt,\y)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
437 |
node[anchor=east] {\y};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
438 |
%labels
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
439 |
\node[below=0.6cm] at (x axis mid) {\bl{a}s};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
440 |
\node[rotate=90, left=1.2cm] at (y axis mid) {secs};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
441 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
442 |
%plots
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
443 |
\draw[color=blue] plot[mark=*, mark options={fill=white}]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
444 |
file {re-python.data};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
445 |
\draw[color=red] plot[mark=triangle*, mark options={fill=white} ]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
446 |
file {nfa.data};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
447 |
\draw[color=brown] plot[mark=pentagon*, mark options={fill=white} ]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
448 |
file {re-ruby.data};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
449 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
450 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
451 |
%legend
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
452 |
\begin{scope}[shift={(4,20)}]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
453 |
\draw[color=blue] (0,0) --
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
454 |
plot[mark=*, mark options={fill=white}] (0.25,0) -- (0.5,0)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
455 |
node[right]{\small Python};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
456 |
\draw[yshift=-\baselineskip, color=brown] (0,0) --
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
457 |
plot[mark=pentagon*, mark options={fill=white}] (0.25,0) -- (0.5,0)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
458 |
node[right]{\small Ruby};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
459 |
\draw[yshift=\baselineskip, color=red] (0,0) --
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
460 |
plot[mark=triangle*, mark options={fill=white}] (0.25,0) -- (0.5,0)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
461 |
node[right]{\small NFA 1};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
462 |
\end{scope}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
463 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
464 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
465 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
466 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
467 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
468 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
469 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
470 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
471 |
\frametitle{Greedy Depth-First}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
472 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
473 |
\hspace{5mm}\mbox{{\lstset{language=Scala}\consolas\fontsize{9}{10}\selectfont
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
474 |
\lstinputlisting{../progs/appG.scala}}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
475 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
476 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
477 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
478 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
479 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
480 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
481 |
\begin{frame}[t]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
482 |
\frametitle{\begin{tabular}{c}\bl{$(a?\{n\}) \cdot a\{n\}$}\end{tabular}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
483 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
484 |
\mbox{}\\[-13mm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
485 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
486 |
\begin{tikzpicture}[y=.2cm, x=.3cm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
487 |
%axis
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
488 |
\draw (0,0) -- coordinate (x axis mid) (30,0);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
489 |
\draw (0,0) -- coordinate (y axis mid) (0,30);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
490 |
%ticks
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
491 |
\foreach \x in {0,5,...,30}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
492 |
\draw (\x,1pt) -- (\x,-3pt)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
493 |
node[anchor=north] {\x};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
494 |
\foreach \y in {0,5,...,30}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
495 |
\draw (1pt,\y) -- (-3pt,\y)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
496 |
node[anchor=east] {\y};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
497 |
%labels
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
498 |
\node[below=0.6cm] at (x axis mid) {\bl{a}s};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
499 |
\node[rotate=90, left=1.2cm] at (y axis mid) {secs};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
500 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
501 |
%plots
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
502 |
\draw[color=blue] plot[mark=*, mark options={fill=white}]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
503 |
file {re-python.data};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
504 |
\draw[color=red] plot[mark=triangle*, mark options={fill=white} ]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
505 |
file {nfasearch.data};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
506 |
\draw[color=brown] plot[mark=pentagon*, mark options={fill=white} ]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
507 |
file {re-ruby.data};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
508 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
509 |
%legend
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
510 |
\begin{scope}[shift={(4,20)}]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
511 |
\draw[color=blue] (0,0) --
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
512 |
plot[mark=*, mark options={fill=white}] (0.25,0) -- (0.5,0)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
513 |
node[right]{\small Python};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
514 |
\draw[yshift=-\baselineskip, color=brown] (0,0) --
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
515 |
plot[mark=pentagon*, mark options={fill=white}] (0.25,0) -- (0.5,0)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
516 |
node[right]{\small Ruby};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
517 |
\draw[yshift=\baselineskip, color=red] (0,0) --
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
518 |
plot[mark=triangle*, mark options={fill=white}] (0.25,0) -- (0.5,0)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
519 |
node[right]{\small NFA 2};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
520 |
\end{scope}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
521 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
522 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
523 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
524 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
525 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
526 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
527 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
528 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
529 |
\begin{frame}<2>[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
530 |
\frametitle{DFA to Rexp}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
531 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
532 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
533 |
\begin{tikzpicture}[scale=2, line width=0.5mm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
534 |
\only<1>{\node[state, initial] (q0) at ( 0,1) {$q_0$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
535 |
\only<2->{\node[state, initial,accepting] (q0) at ( 0,1) {$q_0$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
536 |
\only<1>{\node[state] (q1) at ( 1,1) {$q_1$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
537 |
\only<2->{\node[state,accepting] (q1) at ( 1,1) {$q_1$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
538 |
\only<1>{\node[state, accepting] (q2) at ( 2,1) {$q_2$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
539 |
\only<2->{\node[state] (q2) at ( 2,1) {$q_2$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
540 |
\path[->] (q0) edge[bend left] node[above] {$a$} (q1)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
541 |
(q1) edge[bend left] node[above] {$b$} (q0)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
542 |
(q2) edge[bend left=50] node[below] {$b$} (q0)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
543 |
(q1) edge node[above] {$a$} (q2)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
544 |
(q2) edge [loop right] node {$a$} ()
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
545 |
(q0) edge [loop below] node {$b$} ()
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
546 |
;
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
547 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
548 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
549 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
550 |
\onslide<3>{How to get from a DFA to a regular expression?}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
551 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
552 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
553 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
554 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
555 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
556 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
557 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
558 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
559 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
560 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
561 |
\begin{tikzpicture}[scale=2, line width=0.5mm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
562 |
\only<1->{\node[state, initial] (q0) at ( 0,1) {$q_0$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
563 |
\only<1->{\node[state] (q1) at ( 1,1) {$q_1$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
564 |
\only<1->{\node[state] (q2) at ( 2,1) {$q_2$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
565 |
\path[->] (q0) edge[bend left] node[above] {$a$} (q1)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
566 |
(q1) edge[bend left] node[above] {$b$} (q0)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
567 |
(q2) edge[bend left=50] node[below] {$b$} (q0)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
568 |
(q1) edge node[above] {$a$} (q2)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
569 |
(q2) edge [loop right] node {$a$} ()
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
570 |
(q0) edge [loop below] node {$b$} ()
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
571 |
;
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
572 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
573 |
\end{center}\pause\bigskip
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
574 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
575 |
\onslide<2->{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
576 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
577 |
\begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
578 |
\bl{$q_0$} & \bl{$=$} & \bl{$2\, q_0 + 3 \,q_1 + 4\, q_2$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
579 |
\bl{$q_1$} & \bl{$=$} & \bl{$2 \,q_0 + 3\, q_1 + 1\, q_2$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
580 |
\bl{$q_2$} & \bl{$=$} & \bl{$1\, q_0 + 5\, q_1 + 2\, q_2$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
581 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
582 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
583 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
584 |
}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
585 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
586 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
587 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
588 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
589 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
590 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
591 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
592 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
593 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
594 |
\begin{tikzpicture}[scale=2, line width=0.5mm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
595 |
\only<1->{\node[state, initial] (q0) at ( 0,1) {$q_0$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
596 |
\only<1->{\node[state] (q1) at ( 1,1) {$q_1$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
597 |
\only<1->{\node[state] (q2) at ( 2,1) {$q_2$};}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
598 |
\path[->] (q0) edge[bend left] node[above] {$a$} (q1)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
599 |
(q1) edge[bend left] node[above] {$b$} (q0)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
600 |
(q2) edge[bend left=50] node[below] {$b$} (q0)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
601 |
(q1) edge node[above] {$a$} (q2)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
602 |
(q2) edge [loop right] node {$a$} ()
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
603 |
(q0) edge [loop below] node {$b$} ()
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
604 |
;
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
605 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
606 |
\end{center}\bigskip
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
607 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
608 |
\onslide<2->{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
609 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
610 |
\begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
611 |
\bl{$q_0$} & \bl{$=$} & \bl{$\epsilon + q_0\,b + q_1\,b + q_2\,b$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
612 |
\bl{$q_1$} & \bl{$=$} & \bl{$q_0\,a$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
613 |
\bl{$q_2$} & \bl{$=$} & \bl{$q_1\,a + q_2\,a$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
614 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
615 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
616 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
617 |
}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
618 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
619 |
\onslide<3->{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
620 |
Arden's Lemma:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
621 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
622 |
If \bl{$q = q\,r + s$}\; then\; \bl{$q = s\, r^*$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
623 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
624 |
}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
625 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
626 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
627 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
628 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
629 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
630 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
631 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
632 |
\frametitle{DFA Minimisation}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
633 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
634 |
\begin{enumerate}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
635 |
\item Take all pairs \bl{$(q, p)$} with \bl{$q \not= p$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
636 |
\item Mark all pairs that accepting and non-accepting states
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
637 |
\item For all unmarked pairs \bl{$(q, p)$} and all characters \bl{$c$} tests wether
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
638 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
639 |
\bl{$(\delta(q, c), \delta(p,c))$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
640 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
641 |
are marked. If yes, then also mark \bl{$(q, p)$}.
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
642 |
\item Repeat last step until no chance.
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
643 |
\item All unmarked pairs can be merged.
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
644 |
\end{enumerate}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
645 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
646 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
647 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
144
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
648 |
|
265
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
649 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
650 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
651 |
\begin{frame}<1-2>[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
652 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
653 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
654 |
\begin{tikzpicture}[>=stealth',very thick,auto,
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
655 |
every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
656 |
\node[state,initial] (q_0) {$q_0$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
657 |
\node[state] (q_1) [right=of q_0] {$q_1$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
658 |
\node[state] (q_2) [below right=of q_0] {$q_2$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
659 |
\node[state] (q_3) [right=of q_2] {$q_3$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
660 |
\node[state, accepting] (q_4) [right=of q_1] {$q_4$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
661 |
\path[->] (q_0) edge node [above] {\alert{$a$}} (q_1);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
662 |
\path[->] (q_1) edge node [above] {\alert{$a$}} (q_4);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
663 |
\path[->] (q_4) edge [loop right] node {\alert{$a, b$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
664 |
\path[->] (q_3) edge node [right] {\alert{$a$}} (q_4);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
665 |
\path[->] (q_2) edge node [above] {\alert{$a$}} (q_3);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
666 |
\path[->] (q_1) edge node [right] {\alert{$b$}} (q_2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
667 |
\path[->] (q_0) edge node [above] {\alert{$b$}} (q_2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
668 |
\path[->] (q_2) edge [loop left] node {\alert{$b$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
669 |
\path[->] (q_3) edge [bend left=95, looseness=1.3] node [below] {\alert{$b$}} (q_0);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
670 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
671 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
672 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
673 |
\mbox{}\\[-20mm]\mbox{}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
674 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
675 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
676 |
\begin{tikzpicture}[>=stealth',very thick,auto,
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
677 |
every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
678 |
\node[state,initial] (q_02) {$q_{0, 2}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
679 |
\node[state] (q_13) [right=of q_02] {$q_{1, 3}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
680 |
\node[state, accepting] (q_4) [right=of q_13] {$q_{4\phantom{,0}}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
681 |
\path[->] (q_02) edge [bend left] node [above] {\alert{$a$}} (q_13);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
682 |
\path[->] (q_13) edge [bend left] node [below] {\alert{$b$}} (q_02);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
683 |
\path[->] (q_02) edge [loop below] node {\alert{$b$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
684 |
\path[->] (q_13) edge node [above] {\alert{$a$}} (q_4);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
685 |
\path[->] (q_4) edge [loop above] node {\alert{$a, b$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
686 |
\end{tikzpicture}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
687 |
minimal automaton
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
688 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
689 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
690 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
691 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
692 |
|
144
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
693 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
694 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
695 |
\mode<presentation>{
|
139
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
696 |
\begin{frame}<1-2>[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
697 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
698 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
699 |
\begin{tikzpicture}[>=stealth',very thick,auto,
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
700 |
every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
701 |
\node[state,initial] (q_0) {$q_0$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
702 |
\node[state] (q_1) [right=of q_0] {$q_1$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
703 |
\node[state] (q_2) [below right=of q_0] {$q_2$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
704 |
\node[state] (q_3) [right=of q_2] {$q_3$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
705 |
\node[state, accepting] (q_4) [right=of q_1] {$q_4$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
706 |
\path[->] (q_0) edge node [above] {\alert{$a$}} (q_1);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
707 |
\path[->] (q_1) edge node [above] {\alert{$a$}} (q_4);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
708 |
\path[->] (q_4) edge [loop right] node {\alert{$a, b$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
709 |
\path[->] (q_3) edge node [right] {\alert{$a$}} (q_4);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
710 |
\path[->] (q_2) edge node [above] {\alert{$a$}} (q_3);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
711 |
\path[->] (q_1) edge node [right] {\alert{$b$}} (q_2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
712 |
\path[->] (q_0) edge node [above] {\alert{$b$}} (q_2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
713 |
\path[->] (q_2) edge [loop left] node {\alert{$b$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
714 |
\path[->] (q_3) edge [bend left=95, looseness=1.3] node [below] {\alert{$b$}} (q_0);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
715 |
\end{tikzpicture}
|
145
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
716 |
\end{center}\pause
|
139
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
717 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
718 |
\mbox{}\\[-20mm]\mbox{}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
719 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
720 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
721 |
\begin{tikzpicture}[>=stealth',very thick,auto,
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
722 |
every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
723 |
\node[state,initial] (q_02) {$q_{0, 2}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
724 |
\node[state] (q_13) [right=of q_02] {$q_{1, 3}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
725 |
\node[state, accepting] (q_4) [right=of q_13] {$q_{4\phantom{,0}}$};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
726 |
\path[->] (q_02) edge [bend left] node [above] {\alert{$a$}} (q_13);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
727 |
\path[->] (q_13) edge [bend left] node [below] {\alert{$b$}} (q_02);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
728 |
\path[->] (q_02) edge [loop below] node {\alert{$b$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
729 |
\path[->] (q_13) edge node [above] {\alert{$a$}} (q_4);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
730 |
\path[->] (q_4) edge [loop above] node {\alert{$a, b$}} ();
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
731 |
\end{tikzpicture}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
732 |
minimal automaton
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
733 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
734 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
735 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
736 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
737 |
|
35
|
738 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
739 |
\mode<presentation>{
|
|
740 |
\begin{frame}[c]
|
33
|
741 |
|
38
|
742 |
\begin{itemize}
|
145
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
743 |
\item Assuming you have the alphabet \bl{$\{a, b, c\}$}\bigskip
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
744 |
\item Give a regular expression that can recognise all strings that have at least one \bl{$b$}.
|
38
|
745 |
\end{itemize}
|
|
746 |
|
33
|
747 |
\end{frame}}
|
|
748 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
749 |
|
|
750 |
|
|
751 |
\end{document}
|
|
752 |
|
|
753 |
%%% Local Variables:
|
|
754 |
%%% mode: latex
|
|
755 |
%%% TeX-master: t
|
|
756 |
%%% End:
|
|
757 |
|