author | Christian Urban <christian.urban@kcl.ac.uk> |
Mon, 19 Oct 2020 14:17:18 +0100 | |
changeset 783 | 06cbaaad3ba8 |
parent 782 | a26a20acd1c2 |
child 784 | 7dac4492b0e6 |
permissions | -rw-r--r-- |
651 | 1 |
% !TEX program = xelatex |
743 | 2 |
\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer} |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
3 |
\usepackage{../slides} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
4 |
\usepackage{../graphics} |
215
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
143
diff
changeset
|
5 |
\usepackage{../langs} |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
143
diff
changeset
|
6 |
\usepackage{../data} |
25 | 7 |
|
781 | 8 |
\usepackage{tcolorbox} |
9 |
\newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black} |
|
10 |
\newtcolorbox{mybox2}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1} |
|
11 |
\newtcolorbox{mybox3}[1]{colback=Cyan!5!white,colframe=Cyan!75!black,fonttitle=\bfseries,title=#1} |
|
12 |
||
13 |
||
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
14 |
\hfuzz=220pt |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
15 |
|
781 | 16 |
\pgfplotsset{compat=1.17} |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
17 |
|
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
18 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}} |
25 | 19 |
|
20 |
% beamer stuff |
|
445 | 21 |
\renewcommand{\slidecaption}{CFL 03, King's College London} |
25 | 22 |
|
23 |
\begin{document} |
|
24 |
||
25 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
26 |
\begin{frame}[t] |
25 | 27 |
\frametitle{% |
28 |
\begin{tabular}{@ {}c@ {}} |
|
29 |
\\[-3mm] |
|
445 | 30 |
\LARGE Compilers and \\[-2mm] |
743 | 31 |
\LARGE Formal Languages\\[3mm] |
25 | 32 |
\end{tabular}} |
33 |
||
651 | 34 |
\normalsize |
25 | 35 |
\begin{center} |
651 | 36 |
\begin{tabular}{ll} |
37 |
Email: & christian.urban at kcl.ac.uk\\ |
|
743 | 38 |
%Office Hours: & Thursdays 12 -- 14\\ |
39 |
%Location: & N7.07 (North Wing, Bush House)\\ |
|
651 | 40 |
Slides \& Progs: & KEATS (also homework is there)\\ |
25 | 41 |
\end{tabular} |
743 | 42 |
\end{center} |
43 |
||
44 |
\begin{center} |
|
45 |
\begin{tikzpicture} |
|
46 |
\node[drop shadow,fill=white,inner sep=0pt] |
|
47 |
{\footnotesize\rowcolors{1}{capri!10}{white} |
|
48 |
\begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline |
|
49 |
1 Introduction, Languages & 6 While-Language \\ |
|
50 |
2 Regular Expressions, Derivatives & 7 Compilation, JVM \\ |
|
51 |
\cellcolor{blue!50} |
|
52 |
3 Automata, Regular Languages & 8 Compiling Functional Languages \\ |
|
53 |
4 Lexing, Tokenising & 9 Optimisations \\ |
|
54 |
5 Grammars, Parsing & 10 LLVM \\ \hline |
|
55 |
\end{tabular}% |
|
56 |
}; |
|
57 |
\end{tikzpicture} |
|
25 | 58 |
\end{center} |
59 |
||
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
60 |
\end{frame} |
445 | 61 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
62 |
||
63 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
776 | 64 |
%\begin{frame}[c] |
65 |
%\frametitle{Scala Book, Exams} |
|
66 |
% |
|
67 |
%\begin{itemize} |
|
68 |
%\item \small https://nms.kcl.ac.uk/christian.urban/ProgInScala2ed.pdf\normalsize |
|
69 |
%\item homework (written exam 80\%) |
|
70 |
%\item coursework (20\%)\bigskip |
|
71 |
%\item short survey at KEATS; to be answered until Sunday |
|
72 |
%\end{itemize} |
|
445 | 73 |
|
776 | 74 |
%\end{frame} |
445 | 75 |
%%%%%%%%%%% |
25 | 76 |
|
133
09efdf5cf07c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
77 |
|
09efdf5cf07c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
78 |
|
09efdf5cf07c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
79 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
25 | 80 |
\begin{frame}[t] |
651 | 81 |
\frametitle{(Basic) Regular Expressions} |
25 | 82 |
|
83 |
\begin{center} |
|
134
e3a8cf96f570
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
84 |
\begin{tabular}{@ {}rrl@ {\hspace{13mm}}l} |
515 | 85 |
\bl{$r$} & \bl{$::=$} & \bl{$\ZERO$} & nothing\\ |
445 | 86 |
& \bl{$\mid$} & \bl{$\ONE$} & empty string / "" / $[]$\\ |
134
e3a8cf96f570
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
87 |
& \bl{$\mid$} & \bl{$c$} & character\\ |
e3a8cf96f570
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
88 |
& \bl{$\mid$} & \bl{$r_1 \cdot r_2$} & sequence\\ |
e3a8cf96f570
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
89 |
& \bl{$\mid$} & \bl{$r_1 + r_2$} & alternative / choice\\ |
e3a8cf96f570
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
90 |
& \bl{$\mid$} & \bl{$r^*$} & star (zero or more)\\ |
e3a8cf96f570
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
91 |
\end{tabular} |
25 | 92 |
\end{center} |
134
e3a8cf96f570
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
93 |
|
e3a8cf96f570
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
94 |
How about ranges \bl{$[a\mbox{-}z]$}, \bl{$r^+$} and \bl{$\sim{}r$}? Do they increase the |
e3a8cf96f570
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
95 |
set of languages we can recognise? |
25 | 96 |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
97 |
\end{frame} |
25 | 98 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
99 |
||
100 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
776 | 101 |
\begin{frame}[t] |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
102 |
\frametitle{Negation} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
103 |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
104 |
Assume you have an alphabet consisting of the letters \bl{$a$}, \bl{$b$} and \bl{$c$} only. |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
105 |
Find a (basic!) regular expression that matches all strings \emph{\alert{except}} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
106 |
\bl{$ab$} and \bl{$ac$}! |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
107 |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
108 |
\end{frame} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
109 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
110 |
|
25 | 111 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
573 | 112 |
\begin{frame}[t] |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
113 |
\frametitle{Automata} |
25 | 114 |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
115 |
A \alert{\bf deterministic finite automaton}, DFA, consists of: |
25 | 116 |
|
117 |
\begin{itemize} |
|
515 | 118 |
\item an alphabet \bl{$\varSigma$} |
574 | 119 |
\item a set of states \bl{$\mbox{Qs}$} |
515 | 120 |
\item one of these states is the start state \bl{$\mbox{Q}_0$} |
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
121 |
\item some states are accepting states \bl{$F$}, and |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
122 |
\item there is transition function \bl{$\delta$}\bigskip |
25 | 123 |
|
124 |
\small |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
125 |
which takes a state as argument and a character and produces a |
515 | 126 |
new state; this function might not be everywhere defined $\Rightarrow$ partial function |
133
09efdf5cf07c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
127 |
\end{itemize} |
09efdf5cf07c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
128 |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
129 |
\begin{center} |
574 | 130 |
\bl{$A(\varSigma, \mbox{Qs}, \mbox{Q}_0, F, \delta)$} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
131 |
\end{center} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
132 |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
133 |
\end{frame} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
134 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
135 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
136 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
137 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
138 |
\begin{frame}[c] |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
139 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
140 |
\begin{center} |
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
141 |
\begin{tikzpicture}[>=stealth',very thick,auto, |
573 | 142 |
every state/.style={minimum size=0pt,inner sep=2pt, |
143 |
draw=blue!50,very thick,fill=blue!20},] |
|
515 | 144 |
\node[state,initial] (Q_0) {$\mbox{Q}_0$}; |
145 |
\node[state] (Q_1) [right=of Q_0] {$\mbox{Q}_1$}; |
|
146 |
\node[state] (Q_2) [below right=of Q_0] {$\mbox{Q}_2$}; |
|
147 |
\node[state] (Q_3) [right=of Q_2] {$\mbox{Q}_3$}; |
|
148 |
\node[state, accepting] (Q_4) [right=of Q_1] {$\mbox{Q}_4$}; |
|
149 |
\path[->] (Q_0) edge node [above] {\alert{$a$}} (Q_1); |
|
150 |
\path[->] (Q_1) edge node [above] {\alert{$a$}} (Q_4); |
|
151 |
\path[->] (Q_4) edge [loop right] node {\alert{$a, b$}} (); |
|
152 |
\path[->] (Q_3) edge node [right] {\alert{$a$}} (Q_4); |
|
153 |
\path[->] (Q_2) edge node [above] {\alert{$a$}} (Q_3); |
|
154 |
\path[->] (Q_1) edge node [right] {\alert{$b$}} (Q_2); |
|
155 |
\path[->] (Q_0) edge node [above] {\alert{$b$}} (Q_2); |
|
156 |
\path[->] (Q_2) edge [loop left] node {\alert{$b$}} (); |
|
157 |
\path[->] (Q_3) edge [bend left=95, looseness=1.3] node [below] {\alert{$b$}} (Q_0); |
|
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
158 |
\end{tikzpicture} |
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
159 |
\end{center} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
160 |
|
573 | 161 |
\mbox{}\\[-14mm] |
162 |
\only<1>{ |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
163 |
\begin{itemize} |
139
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
138
diff
changeset
|
164 |
\item the start state can be an accepting state |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
165 |
\item it is possible that there is no accepting state |
139
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
138
diff
changeset
|
166 |
\item all states might be accepting (but this does not necessarily mean all strings are accepted) |
573 | 167 |
\end{itemize}} |
168 |
\only<2>{ |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
169 |
for this automaton \bl{$\delta$} is the function\\ |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
170 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
171 |
\begin{center} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
172 |
\begin{tabular}{lll} |
515 | 173 |
\bl{$(\mbox{Q}_0, a) \rightarrow \mbox{Q}_1$} & \bl{$(\mbox{Q}_1, a) \rightarrow \mbox{Q}_4$} |
174 |
& \bl{$(\mbox{Q}_4, a) \rightarrow \mbox{Q}_4$}\\ |
|
175 |
\bl{$(\mbox{Q}_0, b) \rightarrow \mbox{Q}_2$} & \bl{$(\mbox{Q}_1, b) \rightarrow \mbox{Q}_2$} & |
|
176 |
\bl{$(\mbox{Q}_4, b) \rightarrow \mbox{Q}_4$}\\ |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
177 |
\end{tabular}\ldots |
573 | 178 |
\end{center} |
179 |
} |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
180 |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
181 |
\end{frame} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
182 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
183 |
|
573 | 184 |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
185 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
186 |
\begin{frame}[t] |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
187 |
\frametitle{Accepting a String} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
188 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
189 |
Given |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
190 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
191 |
\begin{center} |
574 | 192 |
\bl{$A(\varSigma, \mbox{Qs}, \mbox{Q}_0, F, \delta)$} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
193 |
\end{center} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
194 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
195 |
you can define |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
196 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
197 |
\begin{center} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
198 |
\begin{tabular}{l} |
778 | 199 |
\bl{$\widehat{\delta}(Q, []) \dn Q$}\\ |
200 |
\bl{$\widehat{\delta}(Q, c::s) \dn \widehat{\delta}(\delta(Q, c), s)$}\\ |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
201 |
\end{tabular} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
202 |
\end{center}\pause |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
203 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
204 |
Whether a string \bl{$s$} is accepted by \bl{$A$}? |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
205 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
206 |
\begin{center} |
517 | 207 |
\hspace{5mm}\bl{$\widehat{\delta}(\mbox{Q}_0, s) \in F$} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
208 |
\end{center} |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
209 |
\end{frame} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
210 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
211 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
212 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
213 |
\begin{frame}[c] |
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
214 |
\frametitle{Regular Languages} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
215 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
216 |
A \alert{\bf language} is a set of strings.\bigskip |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
217 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
218 |
A \alert{\bf regular expression} specifies a language.\bigskip |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
219 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
220 |
A language is \alert{\bf regular} iff there exists |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
221 |
a regular expression that recognises all its strings.\bigskip\bigskip\pause |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
222 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
223 |
not all languages are regular, e.g.~\bl{$a^nb^n$} is not |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
224 |
\end{frame} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
225 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
226 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
227 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
228 |
\begin{frame}[c] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
229 |
\frametitle{Regular Languages (2)} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
230 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
231 |
A language is \alert{\bf regular} iff there exists a regular |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
232 |
expression that recognises all its strings.\bigskip\medskip |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
233 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
234 |
or {\bf equivalently}\bigskip\medskip |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
235 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
236 |
A language is \alert{\bf regular} iff there exists a |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
237 |
deterministic finite automaton that recognises all its |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
238 |
strings. |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
239 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
240 |
\end{frame} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
241 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
242 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
243 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
244 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
245 |
\begin{frame}[c] |
348
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
246 |
\frametitle{\begin{tabular}{c} |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
247 |
Non-Deterministic\\[-1mm] |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
248 |
Finite Automata\end{tabular}} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
249 |
|
779 | 250 |
\bl{$N(\varSigma, \mbox{Qs}, \mbox{Qs}_0, F, \rho)$}\\ |
251 |
A non-deterministic finite automaton (NFA) consists of: |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
252 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
253 |
\begin{itemize} |
779 | 254 |
\item a finite set of states, \bl{$Qs$} |
255 |
\item \underline{some} these states are the start states, \bl{$Qs_0$} |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
256 |
\item some states are accepting states, and |
779 | 257 |
\item there is transition \alert{relation}, \bl{$\rho$}\medskip |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
258 |
\end{itemize} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
259 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
260 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
261 |
\begin{center} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
262 |
\begin{tabular}{c} |
515 | 263 |
\bl{$(\mbox{Q}_1, a) \rightarrow \mbox{Q}_2$}\\ |
264 |
\bl{$(\mbox{Q}_1, a) \rightarrow \mbox{Q}_3$}\\ |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
265 |
\end{tabular} |
515 | 266 |
\bl{\ldots} |
267 |
\hspace{10mm}\pause |
|
268 |
\bl{$(\mbox{Q}_1, a) \rightarrow \{\mbox{Q}_2, \mbox{Q}_3\}$} |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
269 |
\end{center} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
270 |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
271 |
\end{frame} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
272 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
273 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
274 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
275 |
\begin{frame}[c] |
515 | 276 |
\frametitle{An NFA Example} |
277 |
||
278 |
% A NFA for (ab* + b)*a |
|
279 |
\begin{center} |
|
280 |
\begin{tikzpicture}[>=stealth',very thick, auto, |
|
281 |
every state/.style={minimum size=0pt,inner sep=3pt, |
|
282 |
draw=blue!50,very thick,fill=blue!20},scale=2] |
|
283 |
\node[state,initial] (Q_0) {$\mbox{Q}_0$}; |
|
284 |
\node[state] (Q_1) [right=of Q_0] {$\mbox{Q}_1$}; |
|
285 |
\node[state, accepting] (Q_2) [right=of Q_1] {$\mbox{Q}_2$}; |
|
286 |
\path[->] (Q_0) edge [loop above] node {\alert{$b$}} (); |
|
287 |
\path[<-] (Q_0) edge node [below] {\alert{$b$}} (Q_1); |
|
288 |
\path[->] (Q_0) edge [bend left] node [above] {\alert{$a$}} (Q_1); |
|
289 |
\path[->] (Q_0) edge [bend right] node [below] {\alert{$a$}} (Q_2); |
|
290 |
\path[->] (Q_1) edge [loop above] node {\alert{$a,b$}} (); |
|
291 |
\path[->] (Q_1) edge node [above] {\alert{$a$}} (Q_2); |
|
292 |
\end{tikzpicture} |
|
293 |
\end{center} |
|
294 |
||
295 |
\end{frame} |
|
296 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
297 |
||
298 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
299 |
\begin{frame}[c] |
|
574 | 300 |
\frametitle{Another Example} |
301 |
||
302 |
For the regular expression \bl{$(.^*)a\,(.^{\{n\}})bc$}\bigskip\bigskip |
|
303 |
||
304 |
% \begin{center} |
|
650 | 305 |
\mbox{}\hspace{-11.5mm} |
574 | 306 |
\begin{tikzpicture}[>=stealth',very thick, auto, |
307 |
every state/.style={minimum size=5pt,inner sep=1pt, |
|
308 |
draw=blue!50,very thick,fill=blue!20},scale=1, node distance=5mm, |
|
309 |
decoration={brace,mirror,amplitude=7}] |
|
310 |
\node[state,initial] (Q_0) {$\;0\;$}; |
|
311 |
\node[state] (Q_1) [right=of Q_0] {$\;1\;$}; |
|
312 |
\node[state] (Q_2) [right=of Q_1] {$\;2\;$}; |
|
313 |
\node (Q_3) [right=of Q_2] {$\hspace{-1mm}\ldots\hspace{-3mm}$}; |
|
314 |
\node[state] (Q_4) [right=of Q_3] {$\;\phantom{1}\;$}; |
|
315 |
\node (Q_5) [right=of Q_4] {$\hspace{-1mm}\ldots\hspace{-3mm}$}; |
|
316 |
\node[state] (Q_6) [right=of Q_5] {\tiny$n+1$}; |
|
317 |
\node[state] (Q_7) [right=of Q_6] {\tiny$n+2$}; |
|
318 |
\node[state,accepting] (Q_8) [right=of Q_7] {\tiny$n+3$}; |
|
319 |
||
320 |
\path[->] (Q_0) edge [loop above] node {$*$} (); |
|
321 |
\path[->] (Q_0) edge node [above] {$a$} (Q_1); |
|
322 |
\path[->] (Q_1) edge node [above] {$*$} (Q_2); |
|
323 |
\path[->] (Q_2) edge node [above] {$*$} (Q_3); |
|
324 |
\path[->] (Q_4) edge node [above] {$*$} (Q_5); |
|
325 |
\path[->] (Q_5) edge node [above] {$*$} (Q_6); |
|
326 |
\path[->] (Q_6) edge node [above] {$b$} (Q_7); |
|
327 |
\path[->] (Q_7) edge node [above] {$c$} (Q_8); |
|
328 |
||
329 |
\draw [decorate] ([yshift=-5mm]Q_1.east) --node[below=3mm]{$n$} ([yshift=-5mm]Q_6.west); |
|
330 |
\end{tikzpicture}\bigskip |
|
331 |
||
332 |
||
333 |
{\small Note the star-transitions: accept any character.} |
|
334 |
||
335 |
\end{frame} |
|
336 |
||
337 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
338 |
\begin{frame}[c] |
|
515 | 339 |
\frametitle{Two Epsilon NFA Examples} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
340 |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
341 |
\small |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
342 |
\begin{center} |
143
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
343 |
\begin{tabular}[t]{c@{\hspace{9mm}}c} |
136
cc19e6cbcb68
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
135
diff
changeset
|
344 |
\begin{tikzpicture}[scale=0.7,>=stealth',very thick, |
cc19e6cbcb68
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
135
diff
changeset
|
345 |
every state/.style={minimum size=0pt,draw=blue!50,very thick,fill=blue!20},] |
215
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
143
diff
changeset
|
346 |
\node[state,initial] (q_0) {$q_0$}; |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
143
diff
changeset
|
347 |
\node[state] (q_1) [above=of q_0] {$q_1$}; |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
143
diff
changeset
|
348 |
\node[state, accepting] (q_2) [below=of q_0] {$q_2$}; |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
143
diff
changeset
|
349 |
\path[->] (q_0) edge node [left] {\alert{$\epsilon$}} (q_1); |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
143
diff
changeset
|
350 |
\path[->] (q_0) edge node [left] {\alert{$\epsilon$}} (q_2); |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
143
diff
changeset
|
351 |
\path[->] (q_0) edge [loop right] node {\alert{$a$}} (); |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
143
diff
changeset
|
352 |
\path[->] (q_1) edge [loop above] node {\alert{$a$}} (); |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
143
diff
changeset
|
353 |
\path[->] (q_2) edge [loop below] node {\alert{$b$}} (); |
143
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
354 |
\end{tikzpicture} & |
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
355 |
|
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
356 |
\raisebox{20mm}{ |
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
357 |
\begin{tikzpicture}[scale=0.7,>=stealth',very thick, |
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
358 |
every state/.style={minimum size=0pt,draw=blue!50,very thick,fill=blue!20},] |
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
359 |
\node[state,initial] (r_1) {$r_1$}; |
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
360 |
\node[state] (r_2) [above=of r_1] {$r_2$}; |
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
361 |
\node[state, accepting] (r_3) [right=of r_1] {$r_3$}; |
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
362 |
\path[->] (r_1) edge node [below] {\alert{$b$}} (r_3); |
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
363 |
\path[->] (r_2) edge [bend left] node [above] {\alert{$a$}} (r_3); |
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
364 |
\path[->] (r_1) edge [bend left] node [left] {\alert{$\epsilon$}} (r_2); |
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
365 |
\path[->] (r_2) edge [bend left] node [right] {\alert{$a$}} (r_1); |
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
366 |
\end{tikzpicture}} |
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
367 |
\end{tabular} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
368 |
\end{center} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
369 |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
370 |
\end{frame} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
371 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
372 |
|
515 | 373 |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
374 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
375 |
\begin{frame}[c] |
779 | 376 |
\frametitle{Thompson: Rexp to $\epsilon$NFA} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
377 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
378 |
\begin{center} |
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
379 |
\begin{tabular}[t]{l@{\hspace{10mm}}l} |
445 | 380 |
\raisebox{1mm}{\bl{$\ZERO$}} & |
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
381 |
\begin{tikzpicture}[scale=0.7,>=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},] |
515 | 382 |
\node[state, initial] (Q_0) {$\mbox{}$}; |
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
383 |
\end{tikzpicture}\\\\ |
445 | 384 |
\raisebox{1mm}{\bl{$\ONE$}} & |
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
385 |
\begin{tikzpicture}[scale=0.7,>=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},] |
515 | 386 |
\node[state, initial, accepting] (Q_0) {$\mbox{}$}; |
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
387 |
\end{tikzpicture}\\\\ |
651 | 388 |
\raisebox{5mm}{\bl{$c$}} & |
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
389 |
\begin{tikzpicture}[scale=0.7,>=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},] |
515 | 390 |
\node[state, initial] (Q_0) {$\mbox{}$}; |
391 |
\node[state, accepting] (Q_1) [right=of Q_0] {$\mbox{}$}; |
|
392 |
\path[->] (Q_0) edge node [below] {\alert{$c$}} (Q_1); |
|
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
393 |
\end{tikzpicture}\\\\ |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
394 |
\end{tabular} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
395 |
\end{center} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
396 |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
397 |
\end{frame} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
398 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
399 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
400 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
401 |
\begin{frame}[t] |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
402 |
\frametitle{Case $r_1\cdot r_2$} |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
403 |
|
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
404 |
\mbox{}\bigskip |
515 | 405 |
\onslide<1->{By recursion we are given two automata:\bigskip} |
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
406 |
|
515 | 407 |
{\centering% |
408 |
\only<1>{% |
|
409 |
\begin{tikzpicture}[node distance=3mm, |
|
410 |
>=stealth',very thick, |
|
411 |
every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20}] |
|
412 |
\node[state, initial] (Q_0) {$\mbox{}$}; |
|
413 |
\node[state, initial] (Q_01) [below=1mm of Q_0] {$\mbox{}$}; |
|
414 |
\node[state, initial] (Q_02) [above=1mm of Q_0] {$\mbox{}$}; |
|
415 |
\node (R_1) [right=of Q_0] {$\ldots$}; |
|
416 |
\node[state, accepting] (T_1) [right=of R_1] {$\mbox{}$}; |
|
417 |
\node[state, accepting] (T_2) [above=of T_1] {$\mbox{}$}; |
|
418 |
\node[state, accepting] (T_3) [below=of T_1] {$\mbox{}$}; |
|
419 |
||
420 |
\node (A_0) [right=2.5cm of T_1] {$\mbox{}$}; |
|
421 |
\node[state, initial] (A_01) [above=1mm of A_0] {$\mbox{}$}; |
|
422 |
\node[state, initial] (A_02) [below=1mm of A_0] {$\mbox{}$}; |
|
423 |
||
424 |
\node (b_1) [right=of A_0] {$\ldots$}; |
|
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
425 |
\node[state, accepting] (c_1) [right=of b_1] {$\mbox{}$}; |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
426 |
\node[state, accepting] (c_2) [above=of c_1] {$\mbox{}$}; |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
427 |
\node[state, accepting] (c_3) [below=of c_1] {$\mbox{}$}; |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
428 |
\begin{pgfonlayer}{background} |
515 | 429 |
\node (1) [rounded corners, inner sep=1mm, thick, |
430 |
draw=black!60, fill=black!20, fit= (Q_0) (R_1) (T_1) (T_2) (T_3)] {}; |
|
431 |
\node (2) [rounded corners, inner sep=1mm, thick, |
|
432 |
draw=black!60, fill=black!20, fit= (A_0) (b_1) (c_1) (c_2) (c_3)] {}; |
|
433 |
\node [yshift=2mm] at (1.north) {$r_1$}; |
|
434 |
\node [yshift=2mm] at (2.north) {$r_2$}; |
|
143
e3fd4c5995ef
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
139
diff
changeset
|
435 |
\end{pgfonlayer} |
515 | 436 |
\end{tikzpicture}} |
437 |
\only<2>{% |
|
438 |
\begin{tikzpicture}[node distance=3mm, |
|
439 |
>=stealth',very thick, |
|
440 |
every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},] |
|
441 |
\node[state, initial] (Q_0) {$\mbox{}$}; |
|
442 |
\node[state, initial] (Q_01) [below=1mm of Q_0] {$\mbox{}$}; |
|
443 |
\node[state, initial] (Q_02) [above=1mm of Q_0] {$\mbox{}$}; |
|
444 |
\node (r_1) [right=of Q_0] {$\ldots$}; |
|
445 |
\node[state] (t_1) [right=of r_1] {$\mbox{}$}; |
|
446 |
\node[state] (t_2) [above=of t_1] {$\mbox{}$}; |
|
447 |
\node[state] (t_3) [below=of t_1] {$\mbox{}$}; |
|
448 |
||
449 |
\node (A_0) [right=2.5cm of t_1] {$\mbox{}$}; |
|
450 |
\node[state] (A_01) [above=1mm of A_0] {$\mbox{}$}; |
|
451 |
\node[state] (A_02) [below=1mm of A_0] {$\mbox{}$}; |
|
452 |
||
453 |
\node (b_1) [right=of A_0] {$\ldots$}; |
|
454 |
\node[state, accepting] (c_1) [right=of b_1] {$\mbox{}$}; |
|
455 |
\node[state, accepting] (c_2) [above=of c_1] {$\mbox{}$}; |
|
456 |
\node[state, accepting] (c_3) [below=of c_1] {$\mbox{}$}; |
|
457 |
\path[->] (t_1) edge (A_01); |
|
458 |
\path[->] (t_2) edge node [above] {$\epsilon$s} (A_01); |
|
459 |
\path[->] (t_3) edge (A_01); |
|
460 |
\path[->] (t_1) edge (A_02); |
|
461 |
\path[->] (t_2) edge (A_02); |
|
462 |
\path[->] (t_3) edge node [below] {$\epsilon$s} (A_02); |
|
463 |
||
464 |
\begin{pgfonlayer}{background} |
|
465 |
\node (3) [rounded corners, inner sep=1mm, thick, |
|
466 |
draw=black!60, fill=black!20, fit= (Q_0) (c_1) (c_2) (c_3)] {}; |
|
467 |
\node [yshift=2mm] at (3.north) {$r_1\cdot r_2$}; |
|
468 |
\end{pgfonlayer} |
|
469 |
\end{tikzpicture}} |
|
470 |
% |
|
471 |
}\bigskip\bigskip |
|
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
472 |
|
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
473 |
\small |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
474 |
We need to (1) change the accepting nodes of the first automaton into non-accepting nodes, and (2) connect them |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
475 |
via $\epsilon$-transitions to the starting state of the second automaton. |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
476 |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
477 |
\end{frame} |
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
478 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
479 |
|
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
480 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
481 |
\begin{frame}[t] |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
482 |
\frametitle{Case $r_1+ r_2$} |
515 | 483 |
\mbox{}\\[-8mm] |
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
484 |
|
515 | 485 |
\onslide<1->{By recursion we are given two automata:\smallskip} |
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
486 |
|
515 | 487 |
\hspace{2cm} |
488 |
\only<1>{% |
|
489 |
\begin{tikzpicture}[node distance=3mm, |
|
490 |
>=stealth',very thick, |
|
491 |
every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20}, |
|
492 |
baseline=(current bounding box.center)] |
|
493 |
\node at (0,0) (1) {$\mbox{}$}; |
|
494 |
\node (2) [above=14mm of 1] {}; |
|
495 |
\node[state, initial] (4) [above=1mm of 2] {$\mbox{}$}; |
|
496 |
\node[state, initial] (5) [below=1mm of 2] {$\mbox{}$}; |
|
497 |
\node[state, initial] (3) [below=10mm of 1] {$\mbox{}$}; |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
498 |
|
515 | 499 |
\node (a) [right=of 2] {$\ldots\,$}; |
500 |
\node (a1) [right=of a] {$$}; |
|
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
501 |
\node[state, accepting] (a2) [above=of a1] {$\mbox{}$}; |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
502 |
\node[state, accepting] (a3) [below=of a1] {$\mbox{}$}; |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
503 |
|
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
504 |
\node (b) [right=of 3] {$\ldots$}; |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
505 |
\node[state, accepting] (b1) [right=of b] {$\mbox{}$}; |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
506 |
\node[state, accepting] (b2) [above=of b1] {$\mbox{}$}; |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
507 |
\node[state, accepting] (b3) [below=of b1] {$\mbox{}$}; |
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
508 |
\begin{pgfonlayer}{background} |
515 | 509 |
\node (1) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (2) (a1) (a2) (a3)] {}; |
510 |
\node (2) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (3) (b1) (b2) (b3)] {}; |
|
511 |
\node [yshift=3mm] at (1.north) {$r_1$}; |
|
512 |
\node [yshift=3mm] at (2.north) {$r_2$}; |
|
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
513 |
\end{pgfonlayer} |
515 | 514 |
\end{tikzpicture}} |
515 |
\only<2>{% |
|
516 |
\begin{tikzpicture}[node distance=3mm, |
|
517 |
>=stealth',very thick, |
|
518 |
every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20}, |
|
519 |
baseline=(current bounding box.center)] |
|
520 |
\node at (0,0) (1) {$\mbox{}$}; |
|
521 |
\node (2) [above=14mm of 1] {$$}; |
|
522 |
\node[state, initial] (4) [above=1mm of 2] {$\mbox{}$}; |
|
523 |
\node[state, initial] (5) [below=1mm of 2] {$\mbox{}$}; |
|
524 |
\node[state, initial] (3) [below=10mm of 1] {$\mbox{}$}; |
|
525 |
||
526 |
\node (a) [right=of 2] {$\ldots\,$}; |
|
527 |
\node (a1) [right=of a] {$$}; |
|
528 |
\node[state, accepting] (a2) [above=of a1] {$\mbox{}$}; |
|
529 |
\node[state, accepting] (a3) [below=of a1] {$\mbox{}$}; |
|
530 |
||
531 |
\node (b) [right=of 3] {$\ldots$}; |
|
532 |
\node[state, accepting] (b1) [right=of b] {$\mbox{}$}; |
|
533 |
\node[state, accepting] (b2) [above=of b1] {$\mbox{}$}; |
|
534 |
\node[state, accepting] (b3) [below=of b1] {$\mbox{}$}; |
|
535 |
||
536 |
%\path[->] (1) edge node [above] {$\epsilon$} (2); |
|
537 |
%\path[->] (1) edge node [below] {$\epsilon$} (3); |
|
538 |
||
539 |
\begin{pgfonlayer}{background} |
|
540 |
\node (3) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (1) (a2) (a3) (b2) (b3)] {}; |
|
541 |
\node [yshift=3mm] at (3.north) {$r_1+ r_2$}; |
|
542 |
\end{pgfonlayer} |
|
543 |
\end{tikzpicture}} |
|
544 |
% |
|
137
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
545 |
|
69cec773736b
added pictures
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
546 |
\small |
515 | 547 |
\mbox{}\\\medskip |
517 | 548 |
We can just put both automata together. |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
549 |
\end{frame} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
550 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
551 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
552 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
553 |
\begin{frame}[c] |
138
b98a0a49c432
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
554 |
\frametitle{Case $r^*$} |
b98a0a49c432
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
555 |
|
515 | 556 |
\onslide<1->{By recursion we are given an automaton for $r$:\smallskip} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
557 |
|
515 | 558 |
\hspace{2cm} |
559 |
\only<1>{\begin{tikzpicture}[node distance=3mm, |
|
560 |
>=stealth',very thick, |
|
561 |
every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20}, |
|
562 |
baseline=(current bounding box.north)] |
|
563 |
\node (2) {$\mbox{}$}; |
|
564 |
\node[state, initial] (4) [above=1mm of 2] {$\mbox{}$}; |
|
565 |
\node[state, initial] (5) [below=1mm of 2] {$\mbox{}$}; |
|
138
b98a0a49c432
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
566 |
\node (a) [right=of 2] {$\ldots$}; |
b98a0a49c432
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
567 |
\node[state, accepting] (a1) [right=of a] {$\mbox{}$}; |
b98a0a49c432
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
568 |
\node[state, accepting] (a2) [above=of a1] {$\mbox{}$}; |
515 | 569 |
\node[state, accepting] (a3) [below=of a1] {$\mbox{}$}; |
570 |
\begin{pgfonlayer}{background} |
|
571 |
\node (1) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (2) (a1) (a2) (a3)] {}; |
|
572 |
\node [yshift=3mm] at (1.north) {$r$}; |
|
573 |
\end{pgfonlayer} |
|
574 |
\end{tikzpicture}} |
|
575 |
\only<2->{\begin{tikzpicture}[node distance=3mm, |
|
576 |
>=stealth',very thick, |
|
577 |
every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20}, |
|
578 |
baseline=(current bounding box.north)] |
|
579 |
\node at (0,0) [state, initial,accepting] (1) {$\mbox{}$}; |
|
580 |
\node (2) [right=16mm of 1] {$\mbox{}$}; |
|
581 |
\node[state] (4) [above=1mm of 2] {$\mbox{}$}; |
|
582 |
\node[state] (5) [below=1mm of 2] {$\mbox{}$}; |
|
583 |
\node (a) [right=of 2] {$\ldots$}; |
|
138
b98a0a49c432
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
584 |
\node[state] (a1) [right=of a] {$\mbox{}$}; |
b98a0a49c432
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
585 |
\node[state] (a2) [above=of a1] {$\mbox{}$}; |
515 | 586 |
\node[state] (a3) [below=of a1] {$\mbox{}$}; |
587 |
\path[->] (1) edge node [below] {$\epsilon$} (4); |
|
588 |
\path[->] (1) edge node [below] {$\epsilon$} (5); |
|
589 |
\path[->] (a1) edge [bend left=45] node [below] {$\epsilon$} (1); |
|
590 |
\path[->] (a2) edge [bend right] node [below] {$\epsilon$} (1); |
|
591 |
\path[->] (a3) edge [bend left=45] node [below] {$\epsilon$} (1); |
|
138
b98a0a49c432
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
592 |
\begin{pgfonlayer}{background} |
515 | 593 |
\node (2) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (1) (a2) (a3)] {}; |
594 |
\node [yshift=3mm] at (2.north) {$r^*$}; |
|
138
b98a0a49c432
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
595 |
\end{pgfonlayer} |
515 | 596 |
\end{tikzpicture}} |
597 |
\bigskip |
|
138
b98a0a49c432
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
598 |
|
139
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
138
diff
changeset
|
599 |
\onslide<3->{ |
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
138
diff
changeset
|
600 |
Why can't we just have an epsilon transition from the accepting states to the starting state?} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
601 |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
602 |
\end{frame} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
603 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
604 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
605 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
606 |
\begin{frame}[c] |
779 | 607 |
\frametitle{\mbox{NFA Breadth-First: \boldmath{}$a^{?\{n\}}\!\cdot\! a^{\{n\}}$}} |
608 |
||
609 |
\begin{tikzpicture} |
|
610 |
\begin{axis}[xlabel={\pcode{a}s}, |
|
611 |
ylabel={time in secs}, |
|
612 |
enlargelimits=false, |
|
613 |
xtick={0,5,...,30}, |
|
614 |
xmax=30, |
|
615 |
ymax=35, |
|
616 |
ytick={0,5,...,30}, |
|
617 |
scaled ticks=false, |
|
618 |
axis lines=left, |
|
619 |
width=9cm, |
|
620 |
height=6cm, |
|
621 |
legend entries={Python,Ruby,my NFA}, |
|
622 |
legend pos=outer north east, |
|
623 |
legend cell align=left] |
|
624 |
\addplot[blue,mark=*, mark options={fill=white}] table {re-python.data}; |
|
625 |
\addplot[brown,mark=pentagon*, mark options={fill=white}] table {re-ruby.data}; |
|
626 |
\addplot[red,mark=triangle*, mark options={fill=red}] table {nfabreadth.data}; |
|
627 |
\end{axis} |
|
628 |
\end{tikzpicture} |
|
629 |
||
630 |
\end{frame} |
|
631 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
632 |
||
633 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
634 |
\begin{frame}[c] |
|
635 |
\frametitle{NFA Breadth-First:\boldmath{}$(a^*)^* \cdot b$} |
|
636 |
||
637 |
\bigskip |
|
638 |
\begin{center} |
|
639 |
\begin{tikzpicture} |
|
640 |
\begin{axis}[ |
|
641 |
xlabel={\pcode{a}s}, |
|
642 |
%%x label style={at={(1.05,0.0)}}, |
|
643 |
ylabel={time in secs}, |
|
644 |
enlargelimits=false, |
|
645 |
xtick={0,10,...,100}, |
|
646 |
xmax=103, |
|
647 |
ymax=35, |
|
648 |
ytick={0,5,...,30}, |
|
649 |
scaled ticks=false, |
|
650 |
axis lines=left, |
|
651 |
width=9cm, |
|
652 |
height=6cm, |
|
653 |
legend entries={Java 8,Python,JavaScript,Swift,Dart,my NFA}, |
|
654 |
legend pos=outer north east, |
|
655 |
legend cell align=left] |
|
656 |
\addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data}; |
|
657 |
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data}; |
|
658 |
\addplot[red,mark=*, mark options={fill=white}] table {re-js.data}; |
|
659 |
\addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data}; |
|
660 |
\addplot[brown,mark=*, mark options={fill=white}] table {re-dart.data}; |
|
661 |
||
662 |
\addplot[red,mark=triangle*, mark options={fill=red}] table {nfabreadth2.data}; |
|
663 |
\end{axis} |
|
664 |
\end{tikzpicture} |
|
665 |
\end{center} |
|
666 |
||
667 |
||
668 |
\end{frame} |
|
669 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
670 |
||
671 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
672 |
\begin{frame}[c] |
|
673 |
\frametitle{NFA Depth-First: \boldmath$a^{?\{n\}} \cdot a^{\{n\}}$} |
|
674 |
||
675 |
\begin{tikzpicture} |
|
676 |
\begin{axis}[xlabel={\pcode{a}s}, |
|
677 |
ylabel={time in secs}, |
|
678 |
enlargelimits=false, |
|
679 |
xtick={0,5,...,30}, |
|
680 |
xmax=30, |
|
681 |
ymax=35, |
|
682 |
ytick={0,5,...,30}, |
|
683 |
scaled ticks=false, |
|
684 |
axis lines=left, |
|
685 |
width=9cm, |
|
686 |
height=6cm, |
|
687 |
legend entries={Python,Ruby,my NFA}, |
|
688 |
legend pos=outer north east, |
|
689 |
legend cell align=left] |
|
690 |
\addplot[blue,mark=*, mark options={fill=white}] table {re-python.data}; |
|
691 |
\addplot[brown,mark=pentagon*, mark options={fill=white}] table {re-ruby.data}; |
|
692 |
\addplot[red,mark=triangle*, mark options={fill=red}] table {nfadepth.data}; |
|
693 |
\end{axis} |
|
694 |
\end{tikzpicture} |
|
695 |
||
696 |
\end{frame} |
|
697 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
698 |
||
699 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
700 |
\begin{frame}[c] |
|
701 |
\frametitle{NFA Depth-First: \boldmath$(a^*)^* \cdot b$} |
|
702 |
||
703 |
\bigskip |
|
704 |
\begin{center} |
|
705 |
\begin{tikzpicture} |
|
706 |
\begin{axis}[ |
|
707 |
xlabel={\pcode{a}s}, |
|
708 |
%%x label style={at={(1.05,0.0)}}, |
|
709 |
ylabel={time in secs}, |
|
710 |
enlargelimits=false, |
|
711 |
xtick={0,15,...,30}, |
|
712 |
xmax=33, |
|
713 |
ymax=35, |
|
714 |
ytick={0,5,...,30}, |
|
715 |
scaled ticks=false, |
|
716 |
axis lines=left, |
|
717 |
width=9cm, |
|
718 |
height=6cm, |
|
719 |
legend entries={Java 8,Python,JavaScript,Swift,Dart,my NFA}, |
|
720 |
legend pos=outer north east, |
|
721 |
legend cell align=left] |
|
722 |
\addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data}; |
|
723 |
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data}; |
|
724 |
\addplot[red,mark=*, mark options={fill=white}] table {re-js.data}; |
|
725 |
\addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data}; |
|
726 |
\addplot[brown,mark=*, mark options={fill=white}] table {re-dart.data}; |
|
727 |
||
728 |
\addplot[red,mark=triangle*, mark options={fill=red}] table {nfadepth2.data}; |
|
729 |
\end{axis} |
|
730 |
\end{tikzpicture} |
|
731 |
\end{center} |
|
732 |
||
733 |
The punchline is that many existing libraries do depth-first search |
|
734 |
in NFAs (with backtracking). |
|
735 |
||
736 |
\end{frame} |
|
737 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
738 |
||
782 | 739 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
740 |
\begin{frame}[c] |
|
741 |
\frametitle{Subset Construction} |
|
742 |
||
743 |
||
744 |
\begin{textblock}{5}(1,3.5) |
|
745 |
\begin{center} |
|
746 |
\begin{tikzpicture}[node distance=6mm,scale=0.7,>=stealth',very thick, |
|
747 |
every state/.style={minimum size=0pt,draw=blue!50,very thick,fill=blue!20},] |
|
748 |
\node[state,initial] (Q_0) {$\mbox{Q}_0$}; |
|
749 |
\node[state] (Q_1) [below=of Q_0] {$\mbox{Q}_1$}; |
|
750 |
\node[state, accepting] (Q_2) [below=of Q_1] {$\mbox{Q}_2$}; |
|
751 |
||
752 |
\path[->] (Q_0) edge node [left] {\alert{$1$}} (Q_1); |
|
753 |
\path[->] (Q_1) edge node [left] {\alert{$0,1$}} (Q_2); |
|
754 |
\path[->] (Q_0) edge [loop right] node {\alert{$0,1$}} (); |
|
755 |
%\path[->] (Q_1) edge [loop above] node {\alert{$a$}} (); |
|
756 |
%\path[->] (Q_2) edge [loop below] node {\alert{$b$}} (); |
|
757 |
\end{tikzpicture} |
|
758 |
\end{center} |
|
759 |
\end{textblock} |
|
760 |
||
761 |
\begin{textblock}{11}(6.5,4) |
|
762 |
\begin{tabular}{r|cl} |
|
763 |
nodes \textcolor{white}{*} & $0$ & $1$\\ |
|
764 |
\hline |
|
765 |
$\{\}$ \textcolor{white}{*} & \onslide<2->{$\{\}$} & \onslide<2->{$\{\}$}\\ |
|
766 |
\onslide<5->{s:} $\{0\}$ \textcolor{white}{*} & \onslide<3->{$\{0\}$} & \onslide<3->{$\{0,1\}$}\\ |
|
767 |
$\{1\}$ \textcolor{white}{*} & \onslide<3->{$\{2\}$} & \onslide<3->{$\{2\}$}\\ |
|
768 |
$\{2\}$ \onslide<5->{*} & \onslide<3->{$\{\}$} & \onslide<3->{$\{\}$}\\ |
|
769 |
$\{0,1\}$ \textcolor{white}{*} &\onslide<4->{$\{0,2\}$} & \onslide<4->{$\{0,1,2\}$}\\ |
|
770 |
$\{0,2\}$ \onslide<5->{*} &\onslide<4->{$\{0\}$} & \onslide<4->{$\{0,1\}$}\\ |
|
771 |
$\{1,2\}$ \onslide<5->{*} & \onslide<4->{$\{2\}$} & \onslide<4->{$\{2\}$}\\ |
|
772 |
$\{0,1,2\}$ \onslide<5->{*}& \onslide<4->{$\{0,2\}$} & \onslide<4->{$\{0,1,2\}$}\\ |
|
773 |
\end{tabular} |
|
774 |
\end{textblock} |
|
775 |
||
776 |
\end{frame} |
|
777 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
779 | 778 |
|
782 | 779 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
780 |
\begin{frame}[c] |
|
781 |
\frametitle{The Result} |
|
782 |
||
783 |
\footnotesize |
|
784 |
\begin{center} |
|
785 |
\begin{tikzpicture}[scale=0.5,>=stealth',very thick, |
|
786 |
every state/.style={minimum size=0pt, |
|
787 |
draw=blue!50,very thick,fill=blue!20}, |
|
788 |
baseline=0mm] |
|
789 |
\node[state,initial] (q0) {$\{0\}$}; |
|
790 |
\node[state] (q01) [right=of q0] {$\{0,1\}$}; |
|
791 |
\node[state,accepting] (q12) [above=of q01] {$\{1,2\}$}; |
|
792 |
\node[state,accepting] (q02) [below=of q01] {$\{0,2\}$}; |
|
793 |
\node[state] (q1) [right=2cm of q12] {$\{1\}$}; |
|
794 |
\node[state,accepting] (q2) [right=2.5cm of q01] {$\{2\}$}; |
|
795 |
\node[state,accepting] (q012) [right=1.5cm of q02] {$\{0,1,2\}$}; |
|
796 |
\node[state] (Qn) [right=of q2] {$\{\}$}; |
|
797 |
||
798 |
\path[->] (q0) edge [loop above] node {\alert{$0$}} (); |
|
799 |
\path[->] (q0) edge node [above] {\alert{$1$}} (q01); |
|
800 |
\path[->] (q02) edge [bend left] node [left] {\alert{$1$}} (q01); |
|
801 |
\path[->] (q02) edge node [below] {\alert{$0$}} (q0); |
|
802 |
\path[->] (q01) edge node [above] {\alert{$1$}} (q012); |
|
803 |
\path[->] (q01) edge [bend left] node [right] {\alert{$0$}} (q02); |
|
804 |
\path[->] (q12) edge node [below] {\alert{$0,1$}} (q2); |
|
805 |
\path[->] (q1) edge node [right] {\alert{$0,1$}} (q2); |
|
806 |
\path[->] (q2) edge node [above] {\alert{$0,1$}} (Qn); |
|
807 |
\path[->] (q012) edge [loop right] node {\alert{$1$}} (); |
|
808 |
\path[->] (q012) edge node [below] {\alert{$0$}} (q02); |
|
809 |
\path[->] (Qn) edge [loop above] node {$\alert{0},\alert{1}$} (); |
|
810 |
\end{tikzpicture} |
|
811 |
\end{center} |
|
812 |
||
813 |
||
814 |
\end{frame} |
|
815 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
816 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
817 |
\begin{frame}[c] |
|
818 |
\frametitle{Removing Dead States} |
|
819 |
||
820 |
\footnotesize |
|
821 |
\begin{center} |
|
822 |
\begin{tabular}{ll} |
|
823 |
\large DFA: & \large (original) NFA:\\ |
|
824 |
\raisebox{0mm}{% |
|
825 |
\begin{tikzpicture}[scale=0.7,>=stealth',very thick, |
|
826 |
every state/.style={minimum size=0pt, |
|
827 |
draw=blue!50,very thick,fill=blue!20}] |
|
828 |
\node[state,initial] (q0) {$\{0\}$}; |
|
829 |
\node[state] (q01) [right=of q0] {$\{0,1\}$}; |
|
830 |
\node[state,accepting] (q02) [below=of q01] {$\{0,2\}$}; |
|
831 |
\node[state,accepting] (q012) [right=1.5cm of q02] {$\{0,1,2\}$}; |
|
832 |
||
833 |
\path[->] (q0) edge [loop above] node {\alert{$0$}} (); |
|
834 |
\path[->] (q0) edge node [above] {\alert{$1$}} (q01); |
|
835 |
\path[->] (q02) edge [bend left] node [left] {\alert{$1$}} (q01); |
|
836 |
\path[->] (q02) edge node [below] {\alert{$0$}} (q0); |
|
837 |
\path[->] (q01) edge node [above] {\alert{$1$}} (q012); |
|
838 |
\path[->] (q01) edge [bend left] node [right] {\alert{$0$}} (q02); |
|
839 |
\path[->] (q012) edge [loop right] node {\alert{$1$}} (); |
|
840 |
\path[->] (q012) edge node [below] {\alert{$0$}} (q02); |
|
841 |
\end{tikzpicture}} |
|
842 |
& |
|
843 |
\begin{tikzpicture}[scale=0.7,>=stealth',very thick, |
|
844 |
every state/.style={minimum size=0pt, |
|
845 |
draw=blue!50,very thick,fill=blue!20},] |
|
846 |
\node[state,initial] (Q_0) {$\mbox{Q}_0$}; |
|
847 |
\node[state] (Q_1) [below=of Q_0] {$\mbox{Q}_1$}; |
|
848 |
\node[state, accepting] (Q_2) [below=of Q_1] {$\mbox{Q}_2$}; |
|
849 |
||
850 |
\path[->] (Q_0) edge node [left] {\alert{$1$}} (Q_1); |
|
851 |
\path[->] (Q_1) edge node [left] {\alert{$0,1$}} (Q_2); |
|
852 |
\path[->] (Q_0) edge [loop right] node {\alert{$0,1$}} (); |
|
853 |
\end{tikzpicture} |
|
854 |
\end{tabular} |
|
855 |
\end{center} |
|
856 |
||
857 |
\end{frame} |
|
858 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
779 | 859 |
|
860 |
||
861 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
862 |
\begin{frame}[c] |
|
782 | 863 |
\frametitle{Subset Construction ($\epsilon$NFA)} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
864 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
865 |
|
662 | 866 |
\begin{textblock}{5}(1,1.5) |
136
cc19e6cbcb68
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
135
diff
changeset
|
867 |
\begin{center} |
515 | 868 |
\begin{tikzpicture}[node distance=6mm,scale=0.7,>=stealth',very thick, |
136
cc19e6cbcb68
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
135
diff
changeset
|
869 |
every state/.style={minimum size=0pt,draw=blue!50,very thick,fill=blue!20},] |
515 | 870 |
\node[state,initial] (Q_0) {$\mbox{Q}_0$}; |
871 |
\node[state] (Q_1) [above=of Q_0] {$\mbox{Q}_1$}; |
|
872 |
\node[state, accepting] (Q_2) [below=of Q_0] {$\mbox{Q}_2$}; |
|
873 |
\path[->] (Q_0) edge node [left] {\alert{$\epsilon$}} (Q_1); |
|
874 |
\path[->] (Q_0) edge node [left] {\alert{$\epsilon$}} (Q_2); |
|
875 |
\path[->] (Q_0) edge [loop right] node {\alert{$a$}} (); |
|
876 |
\path[->] (Q_1) edge [loop above] node {\alert{$a$}} (); |
|
877 |
\path[->] (Q_2) edge [loop below] node {\alert{$b$}} (); |
|
136
cc19e6cbcb68
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
135
diff
changeset
|
878 |
\end{tikzpicture} |
cc19e6cbcb68
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
135
diff
changeset
|
879 |
\end{center} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
880 |
\end{textblock} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
881 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
882 |
\begin{textblock}{11}(6.5,4.5) |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
883 |
\begin{tabular}{r|cl} |
139
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
138
diff
changeset
|
884 |
nodes \textcolor{white}{*} & $a$ & $b$\\ |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
885 |
\hline |
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
886 |
$\{\}$ \textcolor{white}{*} & \onslide<2->{$\{\}$} & \onslide<2->{$\{\}$}\\ |
139
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
138
diff
changeset
|
887 |
$\{0\}$ \textcolor{white}{*} & \onslide<3->{$\{0,1,2\}$} & \onslide<3->{$\{2\}$}\\ |
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
888 |
$\{1\}$ \textcolor{white}{*} & \onslide<3->{$\{1\}$} & \onslide<3->{$\{\}$}\\ |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
889 |
$\{2\}$ \onslide<5->{*} & \onslide<3->{$\{\}$} & \onslide<3->{$\{2\}$}\\ |
139
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
138
diff
changeset
|
890 |
$\{0,1\}$ \textcolor{white}{*} &\onslide<4->{$\{0,1,2\}$} & \onslide<4->{$\{2\}$}\\ |
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
138
diff
changeset
|
891 |
$\{0,2\}$ \onslide<5->{*} &\onslide<4->{$\{0,1,2\}$} & \onslide<4->{$\{2\}$}\\ |
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
138
diff
changeset
|
892 |
$\{1,2\}$ \onslide<5->{*} & \onslide<4->{$\{1\}$} & \onslide<4->{$\{2\}$}\\ |
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
138
diff
changeset
|
893 |
\onslide<5->{s:} $\{0,1,2\}$ \onslide<5->{*}& \onslide<4->{$\{0,1,2\}$} & \onslide<4->{$\{2\}$}\\ |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
894 |
\end{tabular} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
895 |
\end{textblock} |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
896 |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
897 |
\end{frame} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
898 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
899 |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
900 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
901 |
\begin{frame}[c] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
902 |
\frametitle{The Result} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
903 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
904 |
\footnotesize |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
905 |
\begin{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
906 |
\begin{tikzpicture}[scale=0.5,>=stealth',very thick, |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
907 |
every state/.style={minimum size=0pt, |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
908 |
draw=blue!50,very thick,fill=blue!20}, |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
909 |
baseline=0mm] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
910 |
\node[state,initial,accepting] (q012) {$\{0,1,2\}$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
911 |
\node[state,accepting] (q02) [right=of q012] {$\{0,2\}$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
912 |
\node[state] (q01) [above=of q02] {$\{0,1\}$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
913 |
\node[state,accepting] (q12) [below=of q02] {$\{1,2\}$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
914 |
\node[state] (q0) [right=2cm of q01] {$\{0\}$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
915 |
\node[state] (q1) [right=2.5cm of q02] {$\{1\}$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
916 |
\node[state,accepting] (q2) [right=1.5cm of q12] {$\{2\}$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
917 |
\node[state] (qn) [right=of q1] {$\{\}$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
918 |
|
348
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
919 |
\path[->] (q012) edge [loop below] node {\alert{$a$}} (); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
920 |
\path[->] (q012) edge node [above] {\alert{$b$}} (q2); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
921 |
\path[->] (q12) edge [bend left] node [below,pos=0.4] {\alert{$a$}} (q1); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
922 |
\path[->] (q12) edge node [below] {\alert{$b$}} (q2); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
923 |
\path[->] (q02) edge node [above] {\alert{$a$}} (q012); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
924 |
\path[->] (q02) edge [bend left] node [above, pos=0.8] {\alert{$b$}} (q2); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
925 |
\path[->] (q01) edge node [below] {\alert{$a$}} (q012); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
926 |
\path[->] (q01) edge [bend left] node [above] {\alert{$b$}} (q2); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
927 |
\path[->] (q0) edge node [below] {\alert{$a$}} (q012); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
928 |
\path[->] (q0) edge node [right, pos=0.2] {\alert{$b$}} (q2); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
929 |
\path[->] (q1) edge [loop above] node {\alert{$a$}} (); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
930 |
\path[->] (q1) edge node [above] {\alert{$b$}} (qn); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
931 |
\path[->] (q2) edge [loop right] node {\alert{$b$}} (); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
932 |
\path[->] (q2) edge node [below] {\alert{$a$}} (qn); |
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
933 |
\path[->] (qn) edge [loop above] node {$\alert{a},\alert{b}$} (); |
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
934 |
\end{tikzpicture} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
935 |
\end{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
936 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
937 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
938 |
\end{frame} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
939 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
940 |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
941 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
942 |
\begin{frame}[c] |
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
943 |
\frametitle{Removing Dead States} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
944 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
945 |
\footnotesize |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
946 |
\begin{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
947 |
\begin{tabular}{ll} |
445 | 948 |
DFA: & (original) NFA:\\ |
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
949 |
\raisebox{10mm}{% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
950 |
\begin{tikzpicture}[scale=0.7,>=stealth',very thick, |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
951 |
every state/.style={minimum size=0pt, |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
952 |
draw=blue!50,very thick,fill=blue!20}] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
953 |
\node[state,initial,accepting] (q012) {$\{0,1,2\}$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
954 |
\node[state,accepting] (q2) [right=of q012] {$\{2\}$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
955 |
\node[state] (qn) [right=of q2] {$\{\}$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
956 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
957 |
\path[->] (q012) edge [loop below] node {\alert{$a$}} (); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
958 |
\path[->] (q012) edge node [above] {\alert{$b$}} (q2); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
959 |
\path[->] (q2) edge [loop below] node {\alert{$b$}} (); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
960 |
\path[->] (q2) edge node [below] {\alert{$a$}} (qn); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
961 |
\path[->] (qn) edge [loop above] node |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
962 |
{$\alert{a},\alert{b}$} (); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
963 |
\end{tikzpicture}} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
964 |
& |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
965 |
\begin{tikzpicture}[scale=0.7,>=stealth',very thick, |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
966 |
every state/.style={minimum size=0pt, |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
967 |
draw=blue!50,very thick,fill=blue!20},] |
515 | 968 |
\node[state,initial] (Q_0) {$\mbox{Q}_0$}; |
969 |
\node[state] (Q_1) [above=of Q_0] {$\mbox{Q}_1$}; |
|
970 |
\node[state, accepting] (Q_2) [below=of Q_0] {$\mbox{Q}_2$}; |
|
971 |
\path[->] (Q_0) edge node [left] {\alert{$\epsilon$}} (Q_1); |
|
972 |
\path[->] (Q_0) edge node [left] {\alert{$\epsilon$}} (Q_2); |
|
973 |
\path[->] (Q_0) edge [loop right] node {\alert{$a$}} (); |
|
974 |
\path[->] (Q_1) edge [loop above] node {\alert{$a$}} (); |
|
975 |
\path[->] (Q_2) edge [loop below] node {\alert{$b$}} (); |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
976 |
\end{tikzpicture} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
977 |
\end{tabular} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
978 |
\end{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
979 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
980 |
\end{frame} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
981 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
982 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
983 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
984 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
985 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
986 |
\begin{frame}[c] |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
987 |
\frametitle{Regexps and Automata} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
988 |
|
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
989 |
\begin{center} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
990 |
\begin{tikzpicture} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
991 |
\node (rexp) {\bl{\bf Regexps}}; |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
992 |
\node (nfa) [right=of rexp] {\bl{\bf NFAs}}; |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
993 |
\node (dfa) [right=of nfa] {\bl{\bf DFAs}}; |
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
994 |
\onslide<2->{\node (mdfa) [right=of dfa] {\bl{\bf \begin{tabular}{c}minimal\\ DFAs\end{tabular}}};} |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
995 |
\path[->, red, line width=2mm] (rexp) edge node [above=4mm, black] {\begin{tabular}{c@{\hspace{9mm}}}Thompson's\\[-1mm] construction\end{tabular}} (nfa); |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
996 |
\path[->, red, line width=2mm] (nfa) edge node [above=4mm, black] {\begin{tabular}{c}subset\\[-1mm] construction\end{tabular}}(dfa); |
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
997 |
\onslide<2->{\path[->, red, line width=2mm] (dfa) edge node [below=9mm, black] {minimisation} (mdfa);} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
998 |
\end{tikzpicture}\\ |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
999 |
\end{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1000 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1001 |
\end{frame} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1002 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1003 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1004 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1005 |
\begin{frame}[c] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1006 |
\frametitle{DFA Minimisation} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1007 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1008 |
\begin{enumerate} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1009 |
\item Take all pairs \bl{$(q, p)$} with \bl{$q \not= p$} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1010 |
\item Mark all pairs that accepting and non-accepting states |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1011 |
\item For all unmarked pairs \bl{$(q, p)$} and all characters \bl{$c$} test whether |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1012 |
\begin{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1013 |
\bl{$(\delta(q, c), \delta(p,c))$} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1014 |
\end{center} |
348
31e89128ccd2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
346
diff
changeset
|
1015 |
are marked. If yes in at least one case, then also mark \bl{$(q, p)$}. |
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1016 |
\item Repeat last step until no change. |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1017 |
\item All unmarked pairs can be merged. |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1018 |
\end{enumerate} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1019 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1020 |
\end{frame} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1021 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1022 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1023 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1024 |
\begin{frame}[c] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1025 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1026 |
\begin{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1027 |
\begin{tikzpicture}[>=stealth',very thick,auto, |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1028 |
every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},] |
515 | 1029 |
\node[state,initial] (Q_0) {$\mbox{Q}_0$}; |
1030 |
\node[state] (Q_1) [right=of Q_0] {$\mbox{Q}_1$}; |
|
1031 |
\node[state] (Q_2) [below right=of Q_0] {$\mbox{Q}_2$}; |
|
1032 |
\node[state] (Q_3) [right=of Q_2] {$\mbox{Q}_3$}; |
|
1033 |
\node[state, accepting] (Q_4) [right=of Q_1] {$\mbox{Q}_4$}; |
|
1034 |
\path[->] (Q_0) edge node [above] {\alert{$a$}} (Q_1); |
|
1035 |
\path[->] (Q_1) edge node [above] {\alert{$a$}} (Q_4); |
|
1036 |
\path[->] (Q_4) edge [loop right] node {\alert{$a, b$}} (); |
|
1037 |
\path[->] (Q_3) edge node [right] {\alert{$a$}} (Q_4); |
|
1038 |
\path[->] (Q_2) edge node [above] {\alert{$a$}} (Q_3); |
|
1039 |
\path[->] (Q_1) edge node [right] {\alert{$b$}} (Q_2); |
|
1040 |
\path[->] (Q_0) edge node [above] {\alert{$b$}} (Q_2); |
|
1041 |
\path[->] (Q_2) edge [loop left] node {\alert{$b$}} (); |
|
1042 |
\path[->] (Q_3) edge [bend left=95, looseness=1.3] node [below] {\alert{$b$}} (Q_0); |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1043 |
\end{tikzpicture} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1044 |
\end{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1045 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1046 |
\mbox{}\\[-20mm]\mbox{} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1047 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1048 |
\begin{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1049 |
\begin{tikzpicture}[scale=0.8,line width=0.8mm] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1050 |
\draw (0,0) -- (4,0); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1051 |
\draw (0,1) -- (4,1); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1052 |
\draw (0,2) -- (3,2); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1053 |
\draw (0,3) -- (2,3); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1054 |
\draw (0,4) -- (1,4); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1055 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1056 |
\draw (0,0) -- (0, 4); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1057 |
\draw (1,0) -- (1, 4); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1058 |
\draw (2,0) -- (2, 3); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1059 |
\draw (3,0) -- (3, 2); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1060 |
\draw (4,0) -- (4, 1); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1061 |
|
515 | 1062 |
\draw (0.5,-0.5) node {$\mbox{Q}_0$}; |
1063 |
\draw (1.5,-0.5) node {$\mbox{Q}_1$}; |
|
1064 |
\draw (2.5,-0.5) node {$\mbox{Q}_2$}; |
|
1065 |
\draw (3.5,-0.5) node {$\mbox{Q}_3$}; |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1066 |
|
515 | 1067 |
\draw (-0.5, 3.5) node {$\mbox{Q}_1$}; |
1068 |
\draw (-0.5, 2.5) node {$\mbox{Q}_2$}; |
|
1069 |
\draw (-0.5, 1.5) node {$\mbox{Q}_3$}; |
|
1070 |
\draw (-0.5, 0.5) node {$\mbox{Q}_4$}; |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1071 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1072 |
\draw (0.5,0.5) node {\large$\star$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1073 |
\draw (1.5,0.5) node {\large$\star$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1074 |
\draw (2.5,0.5) node {\large$\star$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1075 |
\draw (3.5,0.5) node {\large$\star$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1076 |
\end{tikzpicture} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1077 |
\end{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1078 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1079 |
\end{frame} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1080 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1081 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1082 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1083 |
\begin{frame}[c] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1084 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1085 |
\begin{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1086 |
\begin{tabular}{@{\hspace{-8mm}}cc@{}} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1087 |
\begin{tikzpicture}[>=stealth',very thick,auto, |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1088 |
every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},] |
515 | 1089 |
\node[state,initial] (Q_0) {$\mbox{Q}_0$}; |
1090 |
\node[state] (Q_1) [right=of Q_0] {$\mbox{Q}_1$}; |
|
1091 |
\node[state] (Q_2) [below right=of Q_0] {$\mbox{Q}_2$}; |
|
1092 |
\node[state] (Q_3) [right=of Q_2] {$\mbox{Q}_3$}; |
|
1093 |
\node[state, accepting] (Q_4) [right=of Q_1] {$\mbox{Q}_4$}; |
|
1094 |
\path[->] (Q_0) edge node [above] {\alert{$a$}} (Q_1); |
|
1095 |
\path[->] (Q_1) edge node [above] {\alert{$a$}} (Q_4); |
|
1096 |
\path[->] (Q_4) edge [loop right] node {\alert{$a, b$}} (); |
|
1097 |
\path[->] (Q_3) edge node [right] {\alert{$a$}} (Q_4); |
|
1098 |
\path[->] (Q_2) edge node [above] {\alert{$a$}} (Q_3); |
|
1099 |
\path[->] (Q_1) edge node [right] {\alert{$b$}} (Q_2); |
|
1100 |
\path[->] (Q_0) edge node [above] {\alert{$b$}} (Q_2); |
|
1101 |
\path[->] (Q_2) edge [loop left] node {\alert{$b$}} (); |
|
1102 |
\path[->] (Q_3) edge [bend left=95, looseness=1.3] node [below] {\alert{$b$}} (Q_0); |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1103 |
\end{tikzpicture} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1104 |
& |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1105 |
\raisebox{9mm}{\begin{tikzpicture}[scale=0.6,line width=0.8mm] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1106 |
\draw (0,0) -- (4,0); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1107 |
\draw (0,1) -- (4,1); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1108 |
\draw (0,2) -- (3,2); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1109 |
\draw (0,3) -- (2,3); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1110 |
\draw (0,4) -- (1,4); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1111 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1112 |
\draw (0,0) -- (0, 4); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1113 |
\draw (1,0) -- (1, 4); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1114 |
\draw (2,0) -- (2, 3); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1115 |
\draw (3,0) -- (3, 2); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1116 |
\draw (4,0) -- (4, 1); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1117 |
|
515 | 1118 |
\draw (0.5,-0.5) node {$\mbox{Q}_0$}; |
1119 |
\draw (1.5,-0.5) node {$\mbox{Q}_1$}; |
|
1120 |
\draw (2.5,-0.5) node {$\mbox{Q}_2$}; |
|
1121 |
\draw (3.5,-0.5) node {$\mbox{Q}_3$}; |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1122 |
|
515 | 1123 |
\draw (-0.5, 3.5) node {$\mbox{Q}_1$}; |
1124 |
\draw (-0.5, 2.5) node {$\mbox{Q}_2$}; |
|
1125 |
\draw (-0.5, 1.5) node {$\mbox{Q}_3$}; |
|
1126 |
\draw (-0.5, 0.5) node {$\mbox{Q}_4$}; |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1127 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1128 |
\draw (0.5,0.5) node {\large$\star$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1129 |
\draw (1.5,0.5) node {\large$\star$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1130 |
\draw (2.5,0.5) node {\large$\star$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1131 |
\draw (3.5,0.5) node {\large$\star$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1132 |
\draw (0.5,1.5) node {\large$\star$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1133 |
\draw (2.5,1.5) node {\large$\star$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1134 |
\draw (0.5,3.5) node {\large$\star$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1135 |
\draw (1.5,2.5) node {\large$\star$}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1136 |
\end{tikzpicture}} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1137 |
\end{tabular} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1138 |
\end{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1139 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1140 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1141 |
\mbox{}\\[-20mm]\mbox{} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1142 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1143 |
\begin{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1144 |
\begin{tikzpicture}[>=stealth',very thick,auto, |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1145 |
every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},] |
515 | 1146 |
\node[state,initial] (Q_02) {$\mbox{Q}_{0, 2}$}; |
1147 |
\node[state] (Q_13) [right=of Q_02] {$\mbox{Q}_{1, 3}$}; |
|
1148 |
\node[state, accepting] (Q_4) [right=of Q_13] {$\mbox{Q}_{4\phantom{,0}}$}; |
|
1149 |
\path[->] (Q_02) edge [bend left] node [above] {\alert{$a$}} (Q_13); |
|
1150 |
\path[->] (Q_13) edge [bend left] node [below] {\alert{$b$}} (Q_02); |
|
1151 |
\path[->] (Q_02) edge [loop below] node {\alert{$b$}} (); |
|
1152 |
\path[->] (Q_13) edge node [above] {\alert{$a$}} (Q_4); |
|
1153 |
\path[->] (Q_4) edge [loop above] node {\alert{$a, b$}} (); |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1154 |
\end{tikzpicture}\\ |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1155 |
minimal automaton |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1156 |
\end{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1157 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1158 |
\end{frame} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1159 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1160 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1161 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1162 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1163 |
\begin{frame}[c] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1164 |
\frametitle{Alternatives} |
573 | 1165 |
\mbox{}\\[-14mm]\mbox{} |
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1166 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1167 |
\begin{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1168 |
\begin{tikzpicture}[>=stealth',very thick,auto, |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1169 |
every state/.style={minimum size=0pt, |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1170 |
inner sep=2pt,draw=blue!50,very thick,fill=blue!20}] |
515 | 1171 |
\only<1>{\node[state,initial] (Q_0) {$\mbox{Q}_0$};} |
1172 |
\only<2->{\node[state,accepting] (Q_0) {$\mbox{Q}_0$};} |
|
1173 |
\node[state] (Q_1) [right=of Q_0] {$\mbox{Q}_1$}; |
|
1174 |
\node[state] (Q_2) [below right=of Q_0] {$\mbox{Q}_2$}; |
|
1175 |
\node[state] (Q_3) [right=of Q_2] {$\mbox{Q}_3$}; |
|
1176 |
\only<1>{\node[state, accepting] (Q_4) [right=of Q_1] {$\mbox{Q}_4$};} |
|
1177 |
\only<2->{\node[state, initial right] (Q_4) [right=of Q_1] {$\mbox{Q}_4$};} |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1178 |
\only<1-2>{ |
515 | 1179 |
\path[->] (Q_0) edge node [above] {\alert{$a$}} (Q_1); |
1180 |
\path[->] (Q_1) edge node [above] {\alert{$a$}} (Q_4); |
|
1181 |
\path[->] (Q_4) edge [loop above] node {\alert{$a, b$}} (); |
|
1182 |
\path[->] (Q_3) edge node [right] {\alert{$a$}} (Q_4); |
|
1183 |
\path[->] (Q_2) edge node [above] {\alert{$a$}} (Q_3); |
|
1184 |
\path[->] (Q_1) edge node [right] {\alert{$b$}} (Q_2); |
|
1185 |
\path[->] (Q_0) edge node [above] {\alert{$b$}} (Q_2); |
|
1186 |
\path[->] (Q_2) edge [loop left] node {\alert{$b$}} (); |
|
1187 |
\path[->] (Q_3) edge [bend left=95, looseness=1.3] node [below] {\alert{$b$}} (Q_0);} |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1188 |
\only<3->{ |
515 | 1189 |
\path[<-] (Q_0) edge node [above] {\alert{$a$}} (Q_1); |
1190 |
\path[<-] (Q_1) edge node [above] {\alert{$a$}} (Q_4); |
|
1191 |
\path[<-] (Q_4) edge [loop above] node {\alert{$a, b$}} (); |
|
1192 |
\path[<-] (Q_3) edge node [right] {\alert{$a$}} (Q_4); |
|
1193 |
\path[<-] (Q_2) edge node [above] {\alert{$a$}} (Q_3); |
|
1194 |
\path[<-] (Q_1) edge node [right] {\alert{$b$}} (Q_2); |
|
1195 |
\path[<-] (Q_0) edge node [above] {\alert{$b$}} (Q_2); |
|
1196 |
\path[<-] (Q_2) edge [loop left] node {\alert{$b$}} (); |
|
1197 |
\path[<-] (Q_3) edge [bend left=95, looseness=1.3] node [below] {\alert{$b$}} (Q_0);} |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1198 |
\end{tikzpicture} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1199 |
\end{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1200 |
\mbox{}\\[-18mm] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1201 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1202 |
\small |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1203 |
\begin{itemize} |
573 | 1204 |
\item<1-> exchange initial / accepting states\\[-2mm] |
1205 |
\item<2-> reverse all edges\\[-2mm] |
|
1206 |
\item<3-> subset construction $\Rightarrow$ DFA\\[-2mm] |
|
1207 |
\item<4-> remove dead states\\[-2mm] |
|
1208 |
\item<5-> repeat once more |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1209 |
\onslide<6->{$\Rightarrow$ minimal DFA} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1210 |
\end{itemize} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1211 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1212 |
\end{frame} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1213 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1214 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1215 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1216 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1217 |
\begin{frame}[c] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1218 |
\frametitle{Regexps and Automata} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1219 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1220 |
\begin{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1221 |
\begin{tikzpicture} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1222 |
\node (rexp) {\bl{\bf Regexps}}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1223 |
\node (nfa) [right=of rexp] {\bl{\bf NFAs}}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1224 |
\node (dfa) [right=of nfa] {\bl{\bf DFAs}}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1225 |
\onslide<1->{\node (mdfa) [right=of dfa] {\bl{\bf \begin{tabular}{c}minimal\\ DFAs\end{tabular}}};} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1226 |
\path[->, red, line width=2mm] (rexp) edge node [above=4mm, black] {\begin{tabular}{c@{\hspace{9mm}}}Thompson's\\[-1mm] construction\end{tabular}} (nfa); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1227 |
\path[->, red, line width=2mm] (nfa) edge node [above=4mm, black] {\begin{tabular}{c}subset\\[-1mm] construction\end{tabular}}(dfa); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1228 |
\onslide<1->{\path[->, red, line width=2mm] (dfa) edge node [below=9mm, black] {minimisation} (mdfa);} |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1229 |
\onslide<2->{\path[->, red, line width=2mm] (dfa) edge [bend left=45] (rexp);} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1230 |
\end{tikzpicture}\\ |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1231 |
\end{center} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1232 |
|
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1233 |
\end{frame} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1234 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1235 |
|
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1236 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1237 |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1238 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1239 |
\begin{frame}<2>[c] |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1240 |
\frametitle{DFA to Rexp} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1241 |
|
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1242 |
\begin{center} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1243 |
\begin{tikzpicture}[scale=2,>=stealth',very thick, |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1244 |
every state/.style={minimum size=0pt,draw=blue!50,very thick,fill=blue!20},] |
515 | 1245 |
\only<1>{\node[state, initial] (q0) at ( 0,1) {$\mbox{Q}_0$};} |
1246 |
\only<2->{\node[state, initial,accepting] (q0) at ( 0,1) {$\mbox{Q}_0$};} |
|
1247 |
\only<1>{\node[state] (q1) at ( 1,1) {$\mbox{Q}_1$};} |
|
1248 |
\only<2->{\node[state,accepting] (q1) at ( 1,1) {$\mbox{Q}_1$};} |
|
1249 |
\only<1>{\node[state, accepting] (q2) at ( 2,1) {$\mbox{Q}_2$};} |
|
1250 |
\only<2->{\node[state] (q2) at ( 2,1) {$\mbox{Q}_2$};} |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1251 |
\path[->] (q0) edge[bend left] node[above] {\alert{$a$}} (q1) |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1252 |
(q1) edge[bend left] node[above] {\alert{$b$}} (q0) |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1253 |
(q2) edge[bend left=50] node[below] {\alert{$b$}} (q0) |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1254 |
(q1) edge node[above] {\alert{$a$}} (q2) |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1255 |
(q2) edge [loop right] node {\alert{$a$}} () |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1256 |
(q0) edge [loop below] node {\alert{$b$}} () |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1257 |
; |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1258 |
\end{tikzpicture} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1259 |
\end{center} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1260 |
|
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1261 |
\onslide<3>{How to get from a DFA to a regular expression?} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1262 |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1263 |
\end{frame} |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1264 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1265 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1266 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1267 |
\begin{frame}[c] |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1268 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1269 |
\begin{center} |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1270 |
\begin{tikzpicture}[scale=2,>=stealth',very thick, |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1271 |
every state/.style={minimum size=0pt,draw=blue!50,very thick,fill=blue!20},] |
783 | 1272 |
\only<1->{\node[state, initial,accepting] (q0) at ( 0,1) {$\mbox{Q}_0$};} |
1273 |
\only<1->{\node[state,accepting] (q1) at ( 1,1) {$\mbox{Q}_1$};} |
|
515 | 1274 |
\only<1->{\node[state] (q2) at ( 2,1) {$\mbox{Q}_2$};} |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1275 |
\path[->] (q0) edge[bend left] node[above] {\alert{$a$}} (q1) |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1276 |
(q1) edge[bend left] node[above] {\alert{$b$}} (q0) |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1277 |
(q2) edge[bend left=50] node[below] {\alert{$b$}} (q0) |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1278 |
(q1) edge node[above] {\alert{$a$}} (q2) |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1279 |
(q2) edge [loop right] node {\alert{$a$}} () |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1280 |
(q0) edge [loop below] node {\alert{$b$}} () |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1281 |
; |
139
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
138
diff
changeset
|
1282 |
\end{tikzpicture} |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1283 |
\end{center}\pause\bigskip |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1284 |
|
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1285 |
\onslide<2->{ |
445 | 1286 |
You know how to solve since school days, no? |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1287 |
\begin{center} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1288 |
\begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
515 | 1289 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$2\, \mbox{Q}_0 + 3 \,\mbox{Q}_1 + 4\, \mbox{Q}_2$}\\ |
1290 |
\bl{$\mbox{Q}_1$} & \bl{$=$} & \bl{$2 \,\mbox{Q}_0 + 3\, \mbox{Q}_1 + 1\, \mbox{Q}_2$}\\ |
|
1291 |
\bl{$\mbox{Q}_2$} & \bl{$=$} & \bl{$1\, \mbox{Q}_0 + 5\, \mbox{Q}_1 + 2\, \mbox{Q}_2$}\\ |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1292 |
|
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1293 |
\end{tabular} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1294 |
\end{center} |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1295 |
} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1296 |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1297 |
\end{frame} |
135
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1298 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1299 |
|
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1300 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1301 |
\begin{frame}[c] |
72b686e1c974
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
134
diff
changeset
|
1302 |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1303 |
\begin{center} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1304 |
\begin{tikzpicture}[scale=2,>=stealth',very thick, |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1305 |
every state/.style={minimum size=0pt,draw=blue!50,very thick,fill=blue!20},] |
515 | 1306 |
\only<1->{\node[state, initial] (q0) at ( 0,1) {$\mbox{Q}_0$};} |
1307 |
\only<1->{\node[state] (q1) at ( 1,1) {$\mbox{Q}_1$};} |
|
1308 |
\only<1->{\node[state] (q2) at ( 2,1) {$\mbox{Q}_2$};} |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1309 |
\path[->] (q0) edge[bend left] node[above] {\alert{$a$}} (q1) |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1310 |
(q1) edge[bend left] node[above] {\alert{$b$}} (q0) |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1311 |
(q2) edge[bend left=50] node[below] {\alert{$b$}} (q0) |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1312 |
(q1) edge node[above] {\alert{$a$}} (q2) |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1313 |
(q2) edge [loop right] node {\alert{$a$}} () |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1314 |
(q0) edge [loop below] node {\alert{$b$}} () |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1315 |
; |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1316 |
\end{tikzpicture} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1317 |
\end{center}\bigskip |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1318 |
|
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1319 |
\onslide<2->{ |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1320 |
\begin{center} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1321 |
\begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
650 | 1322 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$\mbox{Q}_0\,b + \mbox{Q}_1\,b + \mbox{Q}_2\,b + \ONE$}\\ |
515 | 1323 |
\bl{$\mbox{Q}_1$} & \bl{$=$} & \bl{$\mbox{Q}_0\,a$}\\ |
1324 |
\bl{$\mbox{Q}_2$} & \bl{$=$} & \bl{$\mbox{Q}_1\,a + \mbox{Q}_2\,a$}\\ |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1325 |
|
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1326 |
\end{tabular} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1327 |
\end{center} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1328 |
} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1329 |
|
783 | 1330 |
|
1331 |
\only<3-9>{\small |
|
1332 |
\begin{textblock}{6}(1,0.8) |
|
1333 |
\begin{bubble}[6.7cm] |
|
1334 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1335 |
\multicolumn{3}{@{}l}{substitute \bl{$\mbox{Q}_1$} into \bl{$\mbox{Q}_0$} \& \bl{$\mbox{Q}_2$}:}\\ |
|
1336 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$\mbox{Q}_0\,b + \mbox{Q}_0\,a\,b + \mbox{Q}_2\,b + \ONE$}\\ |
|
1337 |
\bl{$\mbox{Q}_2$} & \bl{$=$} & \bl{$\mbox{Q}_0\,a\,a + \mbox{Q}_2\,a$} |
|
1338 |
\end{tabular} |
|
1339 |
\end{bubble} |
|
1340 |
\end{textblock}} |
|
1341 |
||
1342 |
\only<4-9>{\small |
|
1343 |
\begin{textblock}{6}(2,4.15) |
|
1344 |
\begin{bubble}[6.7cm] |
|
1345 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1346 |
\multicolumn{3}{@{}l}{simplifying \bl{$\mbox{Q}_0$}:}\\ |
|
1347 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$\mbox{Q}_0\,(b + a\,b) + \mbox{Q}_2\,b + \ONE$}\\ |
|
1348 |
\bl{$\mbox{Q}_2$} & \bl{$=$} & \bl{$\mbox{Q}_0\,a\,a + \mbox{Q}_2\,a$} |
|
1349 |
\end{tabular} |
|
1350 |
\end{bubble} |
|
1351 |
\end{textblock}} |
|
1352 |
||
1353 |
\only<6-9>{\small |
|
1354 |
\begin{textblock}{6}(3,7.55) |
|
1355 |
\begin{bubble}[6.7cm] |
|
1356 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1357 |
\multicolumn{3}{@{}l}{Arden for \bl{$\mbox{Q}_2$}:}\\ |
|
1358 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$\mbox{Q}_0\,(b + a\,b) + \mbox{Q}_2\,b + \ONE$}\\ |
|
1359 |
\bl{$\mbox{Q}_2$} & \bl{$=$} & \bl{$\mbox{Q}_0\,a\,a\,(a^*)$} |
|
1360 |
\end{tabular} |
|
1361 |
\end{bubble} |
|
1362 |
\end{textblock}} |
|
1363 |
||
1364 |
\only<7-9>{\small |
|
1365 |
\begin{textblock}{6}(4,10.9) |
|
1366 |
\begin{bubble}[7.5cm] |
|
1367 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1368 |
\multicolumn{3}{@{}l}{Substitute \bl{$\mbox{Q}_2$} and simplify:}\\ |
|
1369 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$\mbox{Q}_0\,(b + a\,b + a\,a\,(a^*)\,b) + \ONE$}\\ |
|
1370 |
\end{tabular} |
|
1371 |
\end{bubble} |
|
1372 |
\end{textblock}} |
|
1373 |
||
1374 |
\only<8-9>{\small |
|
1375 |
\begin{textblock}{6}(5,13.4) |
|
1376 |
\begin{bubble}[7.5cm] |
|
1377 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1378 |
\multicolumn{3}{@{}l}{Arden again for \bl{$\mbox{Q}_0$}:}\\ |
|
1379 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$(b + a\,b + a\,a\,(a^*)\,b)^*$}\\ |
|
1380 |
\end{tabular} |
|
1381 |
\end{bubble} |
|
1382 |
\end{textblock}} |
|
1383 |
||
1384 |
||
1385 |
\only<9-10>{\small |
|
1386 |
\begin{textblock}{6}(6,11.5) |
|
1387 |
\begin{bubble}[6.7cm] |
|
1388 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1389 |
\multicolumn{3}{@{}l}{Finally:}\\ |
|
1390 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$(b + a\,b + a\,a\,(a^*)\,b)^*$}\\ |
|
1391 |
\bl{$\mbox{Q}_1$} & \bl{$=$} & \bl{$(b + a\,b + a\,a\,(a^*)\,b)^*\,a$}\\ |
|
1392 |
\bl{$\mbox{Q}_2$} & \bl{$=$} & \bl{$(b + a\,b + a\,a\,(a^*)\,b)^*\,a\,a\,(a^*)$}\\ |
|
1393 |
\end{tabular} |
|
1394 |
\end{bubble} |
|
1395 |
\end{textblock}} |
|
1396 |
||
1397 |
||
1398 |
||
1399 |
||
1400 |
||
1401 |
\only<5-6>{ |
|
1402 |
\begin{textblock}{6}(0.7,11.9) |
|
1403 |
\begin{bubble}[6.7cm] |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1404 |
Arden's Lemma: |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1405 |
\begin{center} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1406 |
If \bl{$q = q\,r + s$}\; then\; \bl{$q = s\, r^*$} |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1407 |
\end{center} |
783 | 1408 |
\end{bubble} |
1409 |
\end{textblock}} |
|
1410 |
||
1411 |
\only<8>{ |
|
1412 |
\begin{textblock}{6}(1.1,7.8) |
|
1413 |
\begin{bubble}[6.7cm] |
|
1414 |
Arden's Lemma: |
|
1415 |
\begin{center} |
|
1416 |
If \bl{$q = q\,r + s$}\; then\; \bl{$q = s\, r^*$} |
|
1417 |
\end{center} |
|
1418 |
\end{bubble} |
|
1419 |
\end{textblock}} |
|
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1420 |
|
346
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1421 |
\end{frame} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1422 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1423 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1424 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1425 |
\begin{frame}[c] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1426 |
\frametitle{Regexps and Automata} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1427 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1428 |
\begin{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1429 |
\begin{tikzpicture} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1430 |
\node (rexp) {\bl{\bf Regexps}}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1431 |
\node (nfa) [right=of rexp] {\bl{\bf NFAs}}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1432 |
\node (dfa) [right=of nfa] {\bl{\bf DFAs}}; |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1433 |
\onslide<1->{\node (mdfa) [right=of dfa] {\bl{\bf \begin{tabular}{c}minimal\\ DFAs\end{tabular}}};} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1434 |
\path[->, red, line width=2mm] (rexp) edge node [above=4mm, black] {\begin{tabular}{c@{\hspace{9mm}}}Thompson's\\[-1mm] construction\end{tabular}} (nfa); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1435 |
\path[->, red, line width=2mm] (nfa) edge node [above=4mm, black] {\begin{tabular}{c}subset\\[-1mm] construction\end{tabular}}(dfa); |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1436 |
\onslide<1->{\path[->, red, line width=2mm] (dfa) edge node [below=9mm, black] {minimisation} (mdfa);} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1437 |
\onslide<1->{\path[->, red, line width=2mm] (dfa) edge [bend left=45] (rexp);} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1438 |
\end{tikzpicture}\\ |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1439 |
\end{center} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1440 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1441 |
\end{frame} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1442 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1443 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1444 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1445 |
\begin{frame}[c] |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1446 |
\frametitle{Regular Languages (3)} |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1447 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1448 |
A language is \alert{\bf regular} iff there exists a regular |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1449 |
expression that recognises all its strings.\bigskip\medskip |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1450 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1451 |
or {\bf equivalently}\bigskip\medskip |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1452 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1453 |
A language is \alert{\bf regular} iff there exists a |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1454 |
deterministic finite automaton that recognises all its |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1455 |
strings.\bigskip\medskip\pause |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1456 |
|
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1457 |
Why is every finite set of strings a regular language? |
a98794b11ac4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
1458 |
\end{frame} |
265
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1459 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1460 |
|
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1461 |
|
332fbe9c91ab
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
1462 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
783 | 1463 |
%\begin{frame}[c] |
1464 |
% |
|
1465 |
%Given the function |
|
1466 |
% |
|
1467 |
%\begin{center} |
|
1468 |
%\bl{\begin{tabular}{r@{\hspace{1mm}}c@{\hspace{1mm}}l} |
|
1469 |
%$rev(\ZERO)$ & $\dn$ & $\ZERO$\\ |
|
1470 |
%$rev(\ONE)$ & $\dn$ & $\ONE$\\ |
|
1471 |
%$rev(c)$ & $\dn$ & $c$\\ |
|
1472 |
%$rev(r_1 + r_2)$ & $\dn$ & $rev(r_1) + rev(r_2)$\\ |
|
1473 |
%$rev(r_1 \cdot r_2)$ & $\dn$ & $rev(r_2) \cdot rev(r_1)$\\ |
|
1474 |
%$rev(r^*)$ & $\dn$ & $rev(r)^*$\\ |
|
1475 |
%\end{tabular}} |
|
1476 |
%\end{center} |
|
1477 |
% |
|
1478 |
% |
|
1479 |
%and the set |
|
1480 |
% |
|
1481 |
%\begin{center} |
|
1482 |
%\bl{$Rev\,A \dn \{s^{-1} \;|\; s \in A\}$} |
|
1483 |
%\end{center} |
|
1484 |
% |
|
1485 |
%prove whether |
|
1486 |
% |
|
1487 |
%\begin{center} |
|
1488 |
%\bl{$L(rev(r)) = Rev (L(r))$} |
|
1489 |
%\end{center} |
|
1490 |
% |
|
1491 |
%\end{frame} |
|
133
09efdf5cf07c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
1492 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
25 | 1493 |
|
1494 |
||
743 | 1495 |
|
1496 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1497 |
\begin{frame}[c] |
|
1498 |
||
1499 |
\begin{center} |
|
1500 |
\begin{tikzpicture}[scale=2,>=stealth',very thick, |
|
1501 |
every state/.style={minimum size=0pt,draw=blue!50,very thick,fill=blue!20},] |
|
1502 |
\only<-7>{\node[state, initial] (q0) at ( 0,1) {$\mbox{Q}_0$};} |
|
1503 |
\only<8->{\node[state, initial,accepting] (q0) at ( 0,1) {$\mbox{Q}_0$};} |
|
1504 |
\only<-7>{\node[state] (q1) at ( 1,1) {$\mbox{Q}_1$};} |
|
1505 |
\only<8->{\node[state,accepting] (q1) at ( 1,1) {$\mbox{Q}_1$};} |
|
1506 |
\node[state] (q2) at ( 2,1) {$\mbox{Q}_2$}; |
|
1507 |
\path[->] (q0) edge[bend left] node[above] {\alert{$a$}} (q1) |
|
1508 |
(q1) edge[bend left] node[above] {\alert{$b$}} (q0) |
|
1509 |
(q2) edge[bend left=50] node[below] {\alert{$b$}} (q0) |
|
1510 |
(q1) edge node[above] {\alert{$a$}} (q2) |
|
1511 |
(q2) edge [loop right] node {\alert{$a$}} () |
|
1512 |
(q0) edge [loop below] node {\alert{$b$}} () |
|
1513 |
; |
|
1514 |
\end{tikzpicture} |
|
1515 |
\end{center}\bigskip |
|
1516 |
||
1517 |
\begin{center} |
|
1518 |
\begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
|
1519 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$\ONE + \mbox{Q}_0\,b + \mbox{Q}_1\,b + \mbox{Q}_2\,b$}\\ |
|
1520 |
\bl{$\mbox{Q}_1$} & \bl{$=$} & \bl{$\mbox{Q}_0\,a$}\\ |
|
1521 |
\bl{$\mbox{Q}_2$} & \bl{$=$} & \bl{$\mbox{Q}_1\,a + \mbox{Q}_2\,a$}\\ |
|
1522 |
\end{tabular} |
|
1523 |
\end{center} |
|
1524 |
||
1525 |
||
1526 |
Arden's Lemma: |
|
1527 |
\begin{center} |
|
1528 |
If \bl{$q = q\,r + s$}\; then\; \bl{$q = s\, r^*$} |
|
1529 |
\end{center} |
|
1530 |
||
1531 |
\only<2-6>{\small |
|
1532 |
\begin{textblock}{6}(1,0.8) |
|
1533 |
\begin{bubble}[6.7cm] |
|
1534 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1535 |
\multicolumn{3}{@{}l}{substitute \bl{$\mbox{Q}_1$} into \bl{$\mbox{Q}_0$} \& \bl{$\mbox{Q}_2$}:}\\ |
|
1536 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$\ONE + \mbox{Q}_0\,b + \mbox{Q}_0\,a\,b + \mbox{Q}_2\,b$}\\ |
|
1537 |
\bl{$\mbox{Q}_2$} & \bl{$=$} & \bl{$\mbox{Q}_0\,a\,a + \mbox{Q}_2\,a$} |
|
1538 |
\end{tabular} |
|
1539 |
\end{bubble} |
|
1540 |
\end{textblock}} |
|
1541 |
||
1542 |
\only<3-6>{\small |
|
1543 |
\begin{textblock}{6}(2,4.15) |
|
1544 |
\begin{bubble}[6.7cm] |
|
1545 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1546 |
\multicolumn{3}{@{}l}{simplifying \bl{$\mbox{Q}_0$}:}\\ |
|
1547 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$\ONE + \mbox{Q}_0\,(b + a\,b) + \mbox{Q}_2\,b$}\\ |
|
1548 |
\bl{$\mbox{Q}_2$} & \bl{$=$} & \bl{$\mbox{Q}_0\,a\,a + \mbox{Q}_2\,a$} |
|
1549 |
\end{tabular} |
|
1550 |
\end{bubble} |
|
1551 |
\end{textblock}} |
|
1552 |
||
1553 |
\only<4-6>{\small |
|
1554 |
\begin{textblock}{6}(3,7.55) |
|
1555 |
\begin{bubble}[6.7cm] |
|
1556 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1557 |
\multicolumn{3}{@{}l}{Arden for \bl{$\mbox{Q}_2$}:}\\ |
|
1558 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$\ONE + \mbox{Q}_0\,(b + a\,b) + \mbox{Q}_2\,b$}\\ |
|
1559 |
\bl{$\mbox{Q}_2$} & \bl{$=$} & \bl{$\mbox{Q}_0\,a\,a\,(a^*)$} |
|
1560 |
\end{tabular} |
|
1561 |
\end{bubble} |
|
1562 |
\end{textblock}} |
|
1563 |
||
1564 |
\only<5-6>{\small |
|
1565 |
\begin{textblock}{6}(4,10.9) |
|
1566 |
\begin{bubble}[7.5cm] |
|
1567 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1568 |
\multicolumn{3}{@{}l}{Substitute \bl{$\mbox{Q}_2$} and simplify:}\\ |
|
1569 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$\ONE + \mbox{Q}_0\,(b + a\,b + a\,a\,(a^*)\,b)$}\\ |
|
1570 |
\end{tabular} |
|
1571 |
\end{bubble} |
|
1572 |
\end{textblock}} |
|
1573 |
||
1574 |
\only<6>{\small |
|
1575 |
\begin{textblock}{6}(5,13.4) |
|
1576 |
\begin{bubble}[7.5cm] |
|
1577 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1578 |
\multicolumn{3}{@{}l}{Arden again for \bl{$\mbox{Q}_0$}:}\\ |
|
1579 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$(b + a\,b + a\,a\,(a^*)\,b)^*$}\\ |
|
1580 |
\end{tabular} |
|
1581 |
\end{bubble} |
|
1582 |
\end{textblock}} |
|
1583 |
||
1584 |
||
1585 |
\only<7->{\small |
|
1586 |
\begin{textblock}{6}(6,11.5) |
|
1587 |
\begin{bubble}[6.7cm] |
|
1588 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1589 |
\multicolumn{3}{@{}l}{Finally:}\\ |
|
1590 |
\bl{$\mbox{Q}_0$} & \bl{$=$} & \bl{$(b + a\,b + a\,a\,(a^*)\,b)^*$}\\ |
|
1591 |
\bl{$\mbox{Q}_1$} & \bl{$=$} & \bl{$(b + a\,b + a\,a\,(a^*)\,b)^*\,a$}\\ |
|
1592 |
\bl{$\mbox{Q}_2$} & \bl{$=$} & \bl{$(b + a\,b + a\,a\,(a^*)\,b)^*\,a\,a\,(a^*)$}\\ |
|
1593 |
\end{tabular} |
|
1594 |
\end{bubble} |
|
1595 |
\end{textblock}} |
|
1596 |
||
1597 |
\end{frame} |
|
1598 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1599 |
||
1600 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1601 |
\begin{frame}[c] |
|
1602 |
\frametitle{Regexps and Automata} |
|
1603 |
||
1604 |
\begin{center} |
|
1605 |
\begin{tikzpicture} |
|
1606 |
\node (rexp) {\bl{\bf Regexps}}; |
|
1607 |
\node (nfa) [right=of rexp] {\bl{\bf NFAs}}; |
|
1608 |
\node (dfa) [right=of nfa] {\bl{\bf DFAs}}; |
|
1609 |
\node (mdfa) [right=of dfa] {\bl{\bf \begin{tabular}{c}minimal\\ DFAs\end{tabular}}}; |
|
1610 |
\path[->,red, line width=2mm] (rexp) edge node [above=4mm, black] |
|
1611 |
{\begin{tabular}{c@{\hspace{9mm}}}Thompson's\\[-1mm] construction\end{tabular}} (nfa); |
|
1612 |
\path[->,red, line width=2mm] (nfa) edge node [above=4mm, black] |
|
1613 |
{\begin{tabular}{c}subset\\[-1mm] construction\end{tabular}}(dfa); |
|
1614 |
\path[->, red, line width=2mm] (dfa) edge node [below=5mm, black] {minimisation} (mdfa); |
|
1615 |
%%\path[->, red, line width=2mm] (dfa) edge [bend left=45] (rexp); |
|
1616 |
\path[->, red, line width=2mm] (dfa) edge [bend left=45] node [below, black] {\begin{tabular}{l}Brzozowski's\\ method\end{tabular}} (rexp); |
|
1617 |
||
1618 |
\end{tikzpicture}\\ |
|
1619 |
\end{center} |
|
1620 |
||
1621 |
\end{frame} |
|
1622 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1623 |
||
1624 |
||
1625 |
||
1626 |
||
1627 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1628 |
% \begin{frame}[c] |
|
1629 |
% \frametitle{DFA to Rexp} |
|
1630 |
||
1631 |
% \begin{center} |
|
1632 |
% \begin{tikzpicture}[scale=2,>=stealth',very thick, |
|
1633 |
% every state/.style={minimum size=0pt, |
|
1634 |
% draw=blue!50,very thick,fill=blue!20},] |
|
1635 |
% \node[state, initial] (q0) at ( 0,1) {$q_0$}; |
|
1636 |
% \node[state] (q1) at ( 1,1) {$q_1$}; |
|
1637 |
% \node[state, accepting] (q2) at ( 2,1) {$q_2$}; |
|
1638 |
% \path[->] (q0) edge[bend left] node[above] {\alert{$a$}} (q1) |
|
1639 |
% (q1) edge[bend left] node[above] {\alert{$b$}} (q0) |
|
1640 |
% (q2) edge[bend left=50] node[below] {\alert{$b$}} (q0) |
|
1641 |
% (q1) edge node[above] {\alert{$a$}} (q2) |
|
1642 |
% (q2) edge [loop right] node {\alert{$a$}} () |
|
1643 |
% (q0) edge [loop below] node {\alert{$b$}} (); |
|
1644 |
% \end{tikzpicture} |
|
1645 |
% \end{center}\bigskip |
|
1646 |
||
1647 |
% \begin{center} |
|
1648 |
% \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l@{\hspace{7mm}}l} |
|
1649 |
% \bl{$q_0$} & \bl{$=$} & \bl{$\ONE + q_0\,b + q_1\,b + q_2\,b$} & (start state)\\ |
|
1650 |
% \bl{$q_1$} & \bl{$=$} & \bl{$q_0\,a$}\\ |
|
1651 |
% \bl{$q_2$} & \bl{$=$} & \bl{$q_1\,a + q_2\,a$}\\ |
|
1652 |
||
1653 |
% \end{tabular} |
|
1654 |
% \end{center} |
|
1655 |
||
1656 |
% Arden's Lemma: |
|
1657 |
% \begin{center} |
|
1658 |
% If \bl{$q = q\,r + s$}\; then\; \bl{$q = s\, r^*$} |
|
1659 |
% \end{center} |
|
1660 |
||
1661 |
||
1662 |
% \end{frame} |
|
1663 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1664 |
||
1665 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1666 |
% \begin{frame}[c] |
|
1667 |
% \frametitle{DFA Minimisation} |
|
1668 |
||
1669 |
% \begin{enumerate} |
|
1670 |
% \item Take all pairs \bl{$(q, p)$} with \bl{$q \not= p$} |
|
1671 |
% \item Mark all pairs that accepting and non-accepting states |
|
1672 |
% \item For all unmarked pairs \bl{$(q, p)$} and all characters \bl{$c$} test whether |
|
1673 |
% \begin{center} |
|
1674 |
% \bl{$(\delta(q, c), \delta(p,c))$} |
|
1675 |
% \end{center} |
|
1676 |
% are marked. If yes, then also mark \bl{$(q, p)$}. |
|
1677 |
% \item Repeat last step until no change. |
|
1678 |
% \item All unmarked pairs can be merged. |
|
1679 |
% \end{enumerate} |
|
1680 |
||
1681 |
% \end{frame} |
|
1682 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1683 |
||
1684 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1685 |
% \begin{frame}[c] |
|
1686 |
||
1687 |
% \begin{center} |
|
1688 |
% \begin{tabular}{@{\hspace{-8mm}}cc@{}} |
|
1689 |
% \begin{tikzpicture}[>=stealth',very thick,auto, |
|
1690 |
% every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},] |
|
1691 |
% \node[state,initial] (q_0) {$q_0$}; |
|
1692 |
% \node[state] (q_1) [right=of q_0] {$q_1$}; |
|
1693 |
% \node[state] (q_2) [below right=of q_0] {$q_2$}; |
|
1694 |
% \node[state] (q_3) [right=of q_2] {$q_3$}; |
|
1695 |
% \node[state, accepting] (q_4) [right=of q_1] {$q_4$}; |
|
1696 |
% \path[->] (q_0) edge node [above] {\alert{$a$}} (q_1); |
|
1697 |
% \path[->] (q_1) edge node [above] {\alert{$a$}} (q_4); |
|
1698 |
% \path[->] (q_4) edge [loop right] node {\alert{$a, b$}} (); |
|
1699 |
% \path[->] (q_3) edge node [right] {\alert{$a$}} (q_4); |
|
1700 |
% \path[->] (q_2) edge node [above] {\alert{$a$}} (q_3); |
|
1701 |
% \path[->] (q_1) edge node [right] {\alert{$b$}} (q_2); |
|
1702 |
% \path[->] (q_0) edge node [above] {\alert{$b$}} (q_2); |
|
1703 |
% \path[->] (q_2) edge [loop left] node {\alert{$b$}} (); |
|
1704 |
% \path[->] (q_3) edge [bend left=95, looseness=1.3] node [below] {\alert{$b$}} (q_0); |
|
1705 |
% \end{tikzpicture} |
|
1706 |
% & |
|
1707 |
% \raisebox{9mm}{\begin{tikzpicture}[scale=0.6,line width=0.8mm] |
|
1708 |
% \draw (0,0) -- (4,0); |
|
1709 |
% \draw (0,1) -- (4,1); |
|
1710 |
% \draw (0,2) -- (3,2); |
|
1711 |
% \draw (0,3) -- (2,3); |
|
1712 |
% \draw (0,4) -- (1,4); |
|
1713 |
||
1714 |
% \draw (0,0) -- (0, 4); |
|
1715 |
% \draw (1,0) -- (1, 4); |
|
1716 |
% \draw (2,0) -- (2, 3); |
|
1717 |
% \draw (3,0) -- (3, 2); |
|
1718 |
% \draw (4,0) -- (4, 1); |
|
1719 |
||
1720 |
% \draw (0.5,-0.5) node {$q_0$}; |
|
1721 |
% \draw (1.5,-0.5) node {$q_1$}; |
|
1722 |
% \draw (2.5,-0.5) node {$q_2$}; |
|
1723 |
% \draw (3.5,-0.5) node {$q_3$}; |
|
1724 |
||
1725 |
% \draw (-0.5, 3.5) node {$q_1$}; |
|
1726 |
% \draw (-0.5, 2.5) node {$q_2$}; |
|
1727 |
% \draw (-0.5, 1.5) node {$q_3$}; |
|
1728 |
% \draw (-0.5, 0.5) node {$q_4$}; |
|
1729 |
||
1730 |
% \draw (0.5,0.5) node {\large$\star$}; |
|
1731 |
% \draw (1.5,0.5) node {\large$\star$}; |
|
1732 |
% \draw (2.5,0.5) node {\large$\star$}; |
|
1733 |
% \draw (3.5,0.5) node {\large$\star$}; |
|
1734 |
% \draw (0.5,1.5) node {\large$\star$}; |
|
1735 |
% \draw (2.5,1.5) node {\large$\star$}; |
|
1736 |
% \draw (0.5,3.5) node {\large$\star$}; |
|
1737 |
% \draw (1.5,2.5) node {\large$\star$}; |
|
1738 |
% \end{tikzpicture}} |
|
1739 |
% \end{tabular} |
|
1740 |
% \end{center} |
|
1741 |
||
1742 |
||
1743 |
% \mbox{}\\[-20mm]\mbox{} |
|
1744 |
||
1745 |
% \begin{center} |
|
1746 |
% \begin{tikzpicture}[>=stealth',very thick,auto, |
|
1747 |
% every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},] |
|
1748 |
% \node[state,initial] (q_02) {$q_{0, 2}$}; |
|
1749 |
% \node[state] (q_13) [right=of q_02] {$q_{1, 3}$}; |
|
1750 |
% \node[state, accepting] (q_4) [right=of q_13] {$q_{4\phantom{,0}}$}; |
|
1751 |
% \path[->] (q_02) edge [bend left] node [above] {\alert{$a$}} (q_13); |
|
1752 |
% \path[->] (q_13) edge [bend left] node [below] {\alert{$b$}} (q_02); |
|
1753 |
% \path[->] (q_02) edge [loop below] node {\alert{$b$}} (); |
|
1754 |
% \path[->] (q_13) edge node [above] {\alert{$a$}} (q_4); |
|
1755 |
% \path[->] (q_4) edge [loop above] node {\alert{$a, b$}} (); |
|
1756 |
% \end{tikzpicture}\\ |
|
1757 |
% minimal automaton |
|
1758 |
% \end{center} |
|
1759 |
||
1760 |
% \end{frame} |
|
1761 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1762 |
||
1763 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1764 |
\begin{frame}[c] |
|
1765 |
\frametitle{Regular Languages} |
|
1766 |
||
1767 |
Two equivalent definitions:\bigskip |
|
1768 |
||
1769 |
\begin{quote}\rm A language is \alert{regular} iff there exists a |
|
1770 |
regular expression that recognises all its strings. |
|
1771 |
\end{quote} |
|
1772 |
||
1773 |
\begin{quote}\rm A language is \alert{regular} iff there exists an |
|
1774 |
automaton that recognises all its strings. |
|
1775 |
\end{quote}\bigskip\bigskip |
|
1776 |
||
1777 |
||
1778 |
\small |
|
1779 |
for example \bl{$a^nb^n$} is not regular |
|
1780 |
\end{frame} |
|
1781 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1782 |
||
1783 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1784 |
\begin{frame}[c] |
|
1785 |
\frametitle{Negation} |
|
1786 |
||
1787 |
Regular languages are closed under negation:\bigskip |
|
1788 |
||
1789 |
\begin{center} |
|
1790 |
\begin{tikzpicture}[scale=2,>=stealth',very thick, |
|
1791 |
every state/.style={minimum size=0pt, |
|
1792 |
draw=blue!50,very thick,fill=blue!20}] |
|
1793 |
\only<1>{\node[state,initial] (q0) at ( 0,1) {$q_0$};} |
|
1794 |
\only<2>{\node[state,initial,accepting] (q0) at ( 0,1) {$q_0$};} |
|
1795 |
\only<1>{\node[state] (q1) at ( 1,1) {$q_1$};} |
|
1796 |
\only<2>{\node[state,accepting] (q1) at ( 1,1) {$q_1$};} |
|
1797 |
\only<1>{\node[state, accepting] (q2) at ( 2,1) {$q_2$};} |
|
1798 |
\only<2>{\node[state] (q2) at ( 2,1) {$q_2$};} |
|
1799 |
\path[->] (q0) edge[bend left] node[above] {\alert{$a$}} (q1) |
|
1800 |
(q1) edge[bend left] node[above] {\alert{$b$}} (q0) |
|
1801 |
(q2) edge[bend left=50] node[below] {\alert{$b$}} (q0) |
|
1802 |
(q1) edge node[above] {\alert{$a$}} (q2) |
|
1803 |
(q2) edge [loop right] node {\alert{$a$}} () |
|
1804 |
(q0) edge [loop below] node {\alert{$b$}} (); |
|
1805 |
\end{tikzpicture} |
|
1806 |
\end{center}\bigskip\bigskip |
|
1807 |
||
1808 |
But requires that the automaton is \alert{completed}! |
|
1809 |
||
1810 |
\end{frame} |
|
1811 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1812 |
||
781 | 1813 |
|
1814 |
\begin{frame}[c] |
|
1815 |
\frametitle{Housekeeping} |
|
782 | 1816 |
\begin{mybox3}{CW 2} |
781 | 1817 |
The deadline for CW2 is 6 November (thanks to Arshdeep Pareek |
1818 |
for pointing this out). |
|
1819 |
\end{mybox3} |
|
1820 |
\end{frame} |
|
1821 |
||
782 | 1822 |
\begin{frame}[t] |
781 | 1823 |
\begin{mybox3}{} |
1824 |
I always thought dfa's needed a transition for each state for each |
|
1825 |
character, and if not it would be an nfa not a dfa. Is there an |
|
1826 |
example that disproves this? |
|
1827 |
\end{mybox3} |
|
1828 |
\end{frame} |
|
1829 |
||
1830 |
\begin{frame}<1-12>[c] |
|
1831 |
\end{frame} |
|
1832 |
||
782 | 1833 |
\begin{frame}[t] |
1834 |
\begin{mybox3}{} |
|
1835 |
Do the regular expression matchers in Python and Java 8 have more |
|
1836 |
features than the one implemented in this module? Or is there |
|
1837 |
another reason for their inefficiency? |
|
1838 |
\end{mybox3} |
|
1839 |
\end{frame} |
|
1840 |
||
25 | 1841 |
\end{document} |
1842 |
||
1843 |
%%% Local Variables: |
|
1844 |
%%% mode: latex |
|
1845 |
%%% TeX-master: t |
|
1846 |
%%% End: |
|
1847 |