slides/slides03.tex
changeset 346 a98794b11ac4
parent 265 332fbe9c91ab
child 348 31e89128ccd2
--- a/slides/slides03.tex	Sat Oct 03 23:30:48 2015 +0100
+++ b/slides/slides03.tex	Mon Oct 05 04:05:20 2015 +0100
@@ -38,7 +38,7 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[c]
-\frametitle{\begin{tabular}{c}Regular Expressions\end{tabular}}
+\frametitle{Regular Expressions}
 
 In programming languages they are often used to recognise:\medskip
 
@@ -60,11 +60,11 @@
 \frametitle{Last Week}
 
 Last week I showed you a regular expression matcher 
-which works provably correct in all cases (we did not
-do the proving part though)
+that works provably correct in all cases (we only
+started with the proving part though)
 
 \begin{center}
-\bl{$matches\,r\,s$} \;\;if and only if \;\; \bl{$s \in L(r)$}
+\bl{$matches\,s\,r$} \;\;if and only if \;\; \bl{$s \in L(r)$}
 \end{center}\bigskip\bigskip 
 
 \small
@@ -123,8 +123,8 @@
 \begin{frame}[c]
 \frametitle{The Idea of the Algorithm}
 
-If we want to recognise the string \bl{$abc$} with regular expression \bl{$r$}
-then\medskip
+If we want to recognise the string \bl{$abc$} with regular
+expression \bl{$r$} then\medskip
 
 \begin{enumerate}
 \item \bl{$Der\,a\,(L(r))$}\pause
@@ -184,7 +184,6 @@
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[c]
 \frametitle{Proofs about Rexps}
@@ -221,23 +220,6 @@
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
-\frametitle{Languages}
-
-A \alert{language} is a set of strings.\bigskip
-
-A \alert{regular expression} specifies a language.\bigskip
-
-A language is \alert{regular} iff there exists
-a regular expression that recognises all its strings.\bigskip\bigskip\pause
-
-\textcolor{gray}{not all languages are regular, e.g.~\bl{$a^nb^n$} is not}
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[t]
 \frametitle{Regular Expressions}
@@ -313,18 +295,17 @@
 \begin{frame}[c]
 \frametitle{Automata}
 
-A \alert{deterministic finite automaton} consists of:
+A \alert{\bf deterministic finite automaton}, DFA, consists of:
 
 \begin{itemize}
-\item a set of states
-\item one of these states is the start state
-\item some states are accepting states, and
-\item there is transition function\medskip 
+\item a set of states \bl{$Q$}
+\item one of these states is the start state \bl{$q_0$}
+\item some states are accepting states \bl{$F$}, and
+\item there is transition function \bl{$\delta$}\bigskip 
 
 \small
 which takes a state as argument and a character and produces a 
-new state\smallskip\\
-this function might not be everywhere defined
+new state; this function might not be everywhere defined
 \end{itemize}
 
 \begin{center}
@@ -356,7 +337,7 @@
 \path[->] (q_2) edge [loop left] node  {\alert{$b$}} ();
 \path[->] (q_3) edge [bend left=95, looseness=1.3] node [below]  {\alert{$b$}} (q_0);
 \end{tikzpicture}
-\end{center}\pause
+\end{center}
 
 
 \begin{itemize}
@@ -432,6 +413,38 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[c]
+\frametitle{Regular Languages}
+
+A \alert{\bf language} is a set of strings.\bigskip
+
+A \alert{\bf regular expression} specifies a language.\bigskip
+
+A language is \alert{\bf regular} iff there exists
+a regular expression that recognises all its strings.\bigskip\bigskip\pause
+
+not all languages are regular, e.g.~\bl{$a^nb^n$} is not
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+\frametitle{Regular Languages (2)}
+
+A language is \alert{\bf regular} iff there exists a regular
+expression that recognises all its strings.\bigskip\medskip
+
+or {\bf equivalently}\bigskip\medskip
+
+A language is \alert{\bf regular} iff there exists a
+deterministic finite automaton that recognises all its
+strings.
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
 \frametitle{\begin{tabular}{c}Non-Deterministic\\[-1mm] Finite Automata\end{tabular}}
 
 A non-deterministic finite automaton consists again of:
@@ -462,6 +475,7 @@
 \begin{frame}[c]
 \frametitle{Two NFA Examples}
 
+\small
 \begin{center}
 \begin{tabular}[t]{c@{\hspace{9mm}}c}
 \begin{tikzpicture}[scale=0.7,>=stealth',very thick,
@@ -613,7 +627,6 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
 \begin{frame}[c]
 \frametitle{Case $r^*$}
 
@@ -652,14 +665,12 @@
 \onslide<3->{
 Why can't we just have an epsilon transition from the accepting states to the starting state?}
 
-\end{frame}}
+\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
 \begin{frame}[c]
-\frametitle{\begin{tabular}{c}Subset Construction\end{tabular}}
+\frametitle{Subset Construction}
 
 
 \begin{textblock}{5}(1,1)
@@ -682,10 +693,10 @@
 \begin{tabular}{r|cl}
 nodes \textcolor{white}{*} & $a$ & $b$\\
 \hline
-$\varnothing$ \textcolor{white}{*} & \onslide<2->{$\varnothing$} & \onslide<2->{$\varnothing$}\\
+$\{\}$ \textcolor{white}{*} & \onslide<2->{$\{\}$} & \onslide<2->{$\{\}$}\\
 $\{0\}$ \textcolor{white}{*} & \onslide<3->{$\{0,1,2\}$} & \onslide<3->{$\{2\}$}\\
-$\{1\}$ \textcolor{white}{*} & \onslide<3->{$\{1\}$} & \onslide<3->{$\varnothing$}\\
-$\{2\}$ \onslide<5->{*} & \onslide<3->{$\varnothing$} & \onslide<3->{$\{2\}$}\\
+$\{1\}$ \textcolor{white}{*} & \onslide<3->{$\{1\}$} & \onslide<3->{$\{\}$}\\
+$\{2\}$ \onslide<5->{*} & \onslide<3->{$\{\}$} & \onslide<3->{$\{2\}$}\\
 $\{0,1\}$ \textcolor{white}{*} &\onslide<4->{$\{0,1,2\}$} & \onslide<4->{$\{2\}$}\\
 $\{0,2\}$ \onslide<5->{*} &\onslide<4->{$\{0,1,2\}$} & \onslide<4->{$\{2\}$}\\
 $\{1,2\}$ \onslide<5->{*} & \onslide<4->{$\{1\}$} & \onslide<4->{$\{2\}$}\\
@@ -693,12 +704,96 @@
 \end{tabular}
 \end{textblock}
 
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
-\end{frame}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+\frametitle{The Result}
+
+\footnotesize
+\begin{center}
+\begin{tikzpicture}[scale=0.5,>=stealth',very thick,
+                    every state/.style={minimum size=0pt,
+                    draw=blue!50,very thick,fill=blue!20},
+                    baseline=0mm]
+\node[state,initial,accepting]  (q012)  {$\{0,1,2\}$};
+\node[state,accepting] (q02) [right=of q012] {$\{0,2\}$};
+\node[state] (q01) [above=of q02] {$\{0,1\}$};
+\node[state,accepting] (q12) [below=of q02] {$\{1,2\}$};
+\node[state] (q0) [right=2cm of q01] {$\{0\}$};
+\node[state] (q1) [right=2.5cm of q02] {$\{1\}$};
+\node[state,accepting] (q2) [right=1.5cm of q12] {$\{2\}$};
+\node[state] (qn) [right=of q1] {$\{\}$};
+
+\path[->] (q012) edge [loop below] node  {$a$} ();
+\path[->] (q012) edge node [above]  {$b$} (q2);
+\path[->] (q12) edge [bend left] node [below,pos=0.4]  {$a$} (q1);
+\path[->] (q12) edge node [below]  {$b$} (q2);
+\path[->] (q02) edge node [above]  {$a$} (q012);
+\path[->] (q02) edge [bend left] node [above, pos=0.8]  {$b$} (q2);
+\path[->] (q01) edge node [below]  {$a$} (q012);
+\path[->] (q01) edge [bend left] node [above]  {$b$} (q2);
+\path[->] (q0) edge node [below]  {$a$} (q012);
+\path[->] (q0) edge node [right, pos=0.2]  {$b$} (q2);
+\path[->] (q1) edge [loop above] node  {$a$} ();
+\path[->] (q1) edge node [above]  {$b$} (qn);
+\path[->] (q2) edge [loop right] node  {$b$} ();
+\path[->] (q2) edge node [below]  {$a$} (qn);
+\path[->] (qn) edge [loop above] node  {$a,b$} ();
+\end{tikzpicture}
+\end{center}
+
+
+\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[c]
+\frametitle{Removing Dead States}
+
+\footnotesize
+\begin{center}
+\begin{tabular}{ll}
+DFA: & NFA:\\
+\raisebox{10mm}{%
+\begin{tikzpicture}[scale=0.7,>=stealth',very thick,
+                    every state/.style={minimum size=0pt,
+                    draw=blue!50,very thick,fill=blue!20}]
+\node[state,initial,accepting]  (q012)  {$\{0,1,2\}$};
+\node[state,accepting] (q2) [right=of q012] {$\{2\}$};
+\node[state] (qn) [right=of q2] {$\{\}$};
+
+\path[->] (q012) edge [loop below] node  {\alert{$a$}} ();
+\path[->] (q012) edge node [above]  {\alert{$b$}} (q2);
+\path[->] (q2) edge [loop below] node  {\alert{$b$}} ();
+\path[->] (q2) edge node [below]  {\alert{$a$}} (qn);
+\path[->] (qn) edge [loop above] node 
+   {$\alert{a},\alert{b}$} ();
+\end{tikzpicture}}
+&
+\begin{tikzpicture}[scale=0.7,>=stealth',very thick,
+                    every state/.style={minimum size=0pt,
+                    draw=blue!50,very thick,fill=blue!20},]
+\node[state,initial]  (q_0)  {$q_0$};
+\node[state] (q_1) [above=of q_0] {$q_1$};
+\node[state, accepting] (q_2) [below=of q_0] {$q_2$};
+\path[->] (q_0) edge node [left]  {\alert{$\epsilon$}} (q_1);
+\path[->] (q_0) edge node [left]  {\alert{$\epsilon$}} (q_2);
+\path[->] (q_0) edge [loop right] node  {\alert{$a$}} ();
+\path[->] (q_1) edge [loop above] node  {\alert{$a$}} ();
+\path[->] (q_2) edge [loop below] node  {\alert{$b$}} ();
+\end{tikzpicture}
+\end{tabular}
+\end{center}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
 \frametitle{Regexps and Automata}
 
 \begin{center}
@@ -706,10 +801,241 @@
 \node (rexp)  {\bl{\bf Regexps}};
 \node (nfa) [right=of rexp] {\bl{\bf NFAs}};
 \node (dfa) [right=of nfa] {\bl{\bf DFAs}};
-\onslide<3->{\node (mdfa) [right=of dfa] {\bl{\bf \begin{tabular}{c}minimal\\ DFAs\end{tabular}}};}
+\onslide<2->{\node (mdfa) [right=of dfa] {\bl{\bf \begin{tabular}{c}minimal\\ DFAs\end{tabular}}};}
 \path[->, red, line width=2mm] (rexp) edge node [above=4mm, black] {\begin{tabular}{c@{\hspace{9mm}}}Thompson's\\[-1mm] construction\end{tabular}} (nfa);
 \path[->, red, line width=2mm] (nfa) edge node [above=4mm, black] {\begin{tabular}{c}subset\\[-1mm] construction\end{tabular}}(dfa);
-\onslide<3->{\path[->, red, line width=2mm] (dfa) edge node [below=9mm, black] {minimisation} (mdfa);}
+\onslide<2->{\path[->, red, line width=2mm] (dfa) edge node [below=9mm, black] {minimisation} (mdfa);}
+\end{tikzpicture}\\
+\end{center}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+\frametitle{DFA Minimisation}
+
+\begin{enumerate}
+\item Take all pairs \bl{$(q, p)$} with \bl{$q \not= p$}
+\item Mark all pairs that accepting and non-accepting states
+\item For  all unmarked pairs \bl{$(q, p)$} and all characters \bl{$c$} test whether
+\begin{center}
+\bl{$(\delta(q, c), \delta(p,c))$}
+\end{center} 
+are marked. If yes, then also mark \bl{$(q, p)$}.
+\item Repeat last step until no change.
+\item All unmarked pairs can be merged.
+\end{enumerate}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+
+\begin{center}
+\begin{tikzpicture}[>=stealth',very thick,auto,
+                             every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},]
+\node[state,initial]  (q_0)  {$q_0$};
+\node[state] (q_1) [right=of q_0] {$q_1$};
+\node[state] (q_2) [below right=of q_0] {$q_2$};
+\node[state] (q_3) [right=of q_2] {$q_3$};
+\node[state, accepting] (q_4) [right=of q_1] {$q_4$};
+\path[->] (q_0) edge node [above]  {\alert{$a$}} (q_1);
+\path[->] (q_1) edge node [above]  {\alert{$a$}} (q_4);
+\path[->] (q_4) edge [loop right] node  {\alert{$a, b$}} ();
+\path[->] (q_3) edge node [right]  {\alert{$a$}} (q_4);
+\path[->] (q_2) edge node [above]  {\alert{$a$}} (q_3);
+\path[->] (q_1) edge node [right]  {\alert{$b$}} (q_2);
+\path[->] (q_0) edge node [above]  {\alert{$b$}} (q_2);
+\path[->] (q_2) edge [loop left] node  {\alert{$b$}} ();
+\path[->] (q_3) edge [bend left=95, looseness=1.3] node [below]  {\alert{$b$}} (q_0);
+\end{tikzpicture}
+\end{center}
+
+\mbox{}\\[-20mm]\mbox{}
+
+\begin{center}
+\begin{tikzpicture}[scale=0.8,line width=0.8mm]
+\draw (0,0) -- (4,0);
+\draw (0,1) -- (4,1);
+\draw (0,2) -- (3,2);
+\draw (0,3) -- (2,3);
+\draw (0,4) -- (1,4);
+
+\draw (0,0) -- (0, 4);
+\draw (1,0) -- (1, 4);
+\draw (2,0) -- (2, 3);
+\draw (3,0) -- (3, 2);
+\draw (4,0) -- (4, 1);
+
+\draw (0.5,-0.5) node {$q_0$}; 
+\draw (1.5,-0.5) node {$q_1$}; 
+\draw (2.5,-0.5) node {$q_2$}; 
+\draw (3.5,-0.5) node {$q_3$};
+ 
+\draw (-0.5, 3.5) node {$q_1$}; 
+\draw (-0.5, 2.5) node {$q_2$}; 
+\draw (-0.5, 1.5) node {$q_3$}; 
+\draw (-0.5, 0.5) node {$q_4$}; 
+
+\draw (0.5,0.5) node {\large$\star$}; 
+\draw (1.5,0.5) node {\large$\star$}; 
+\draw (2.5,0.5) node {\large$\star$}; 
+\draw (3.5,0.5) node {\large$\star$};
+\end{tikzpicture}
+\end{center}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+
+\begin{center}
+\begin{tabular}{@{\hspace{-8mm}}cc@{}}
+\begin{tikzpicture}[>=stealth',very thick,auto,
+                             every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},]
+\node[state,initial]  (q_0)  {$q_0$};
+\node[state] (q_1) [right=of q_0] {$q_1$};
+\node[state] (q_2) [below right=of q_0] {$q_2$};
+\node[state] (q_3) [right=of q_2] {$q_3$};
+\node[state, accepting] (q_4) [right=of q_1] {$q_4$};
+\path[->] (q_0) edge node [above]  {\alert{$a$}} (q_1);
+\path[->] (q_1) edge node [above]  {\alert{$a$}} (q_4);
+\path[->] (q_4) edge [loop right] node  {\alert{$a, b$}} ();
+\path[->] (q_3) edge node [right]  {\alert{$a$}} (q_4);
+\path[->] (q_2) edge node [above]  {\alert{$a$}} (q_3);
+\path[->] (q_1) edge node [right]  {\alert{$b$}} (q_2);
+\path[->] (q_0) edge node [above]  {\alert{$b$}} (q_2);
+\path[->] (q_2) edge [loop left] node  {\alert{$b$}} ();
+\path[->] (q_3) edge [bend left=95, looseness=1.3] node [below]  {\alert{$b$}} (q_0);
+\end{tikzpicture}
+&
+\raisebox{9mm}{\begin{tikzpicture}[scale=0.6,line width=0.8mm]
+\draw (0,0) -- (4,0);
+\draw (0,1) -- (4,1);
+\draw (0,2) -- (3,2);
+\draw (0,3) -- (2,3);
+\draw (0,4) -- (1,4);
+
+\draw (0,0) -- (0, 4);
+\draw (1,0) -- (1, 4);
+\draw (2,0) -- (2, 3);
+\draw (3,0) -- (3, 2);
+\draw (4,0) -- (4, 1);
+
+\draw (0.5,-0.5) node {$q_0$}; 
+\draw (1.5,-0.5) node {$q_1$}; 
+\draw (2.5,-0.5) node {$q_2$}; 
+\draw (3.5,-0.5) node {$q_3$};
+ 
+\draw (-0.5, 3.5) node {$q_1$}; 
+\draw (-0.5, 2.5) node {$q_2$}; 
+\draw (-0.5, 1.5) node {$q_3$}; 
+\draw (-0.5, 0.5) node {$q_4$}; 
+
+\draw (0.5,0.5) node {\large$\star$}; 
+\draw (1.5,0.5) node {\large$\star$}; 
+\draw (2.5,0.5) node {\large$\star$}; 
+\draw (3.5,0.5) node {\large$\star$};
+\draw (0.5,1.5) node {\large$\star$}; 
+\draw (2.5,1.5) node {\large$\star$}; 
+\draw (0.5,3.5) node {\large$\star$}; 
+\draw (1.5,2.5) node {\large$\star$}; 
+\end{tikzpicture}}
+\end{tabular}
+\end{center}
+
+
+\mbox{}\\[-20mm]\mbox{}
+
+\begin{center}
+\begin{tikzpicture}[>=stealth',very thick,auto,
+                             every state/.style={minimum size=0pt,inner sep=2pt,draw=blue!50,very thick,fill=blue!20},]
+\node[state,initial]  (q_02)  {$q_{0, 2}$};
+\node[state] (q_13) [right=of q_02] {$q_{1, 3}$};
+\node[state, accepting] (q_4) [right=of q_13] {$q_{4\phantom{,0}}$};
+\path[->] (q_02) edge [bend left] node [above]  {\alert{$a$}} (q_13);
+\path[->] (q_13) edge [bend left] node [below]  {\alert{$b$}} (q_02);
+\path[->] (q_02) edge [loop below] node  {\alert{$b$}} ();
+\path[->] (q_13) edge node [above]  {\alert{$a$}} (q_4);
+\path[->] (q_4) edge [loop above] node  {\alert{$a, b$}} ();
+\end{tikzpicture}\\
+minimal automaton
+\end{center}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+\frametitle{Alternatives}
+\mbox{}\\[-17mm]\mbox{}
+
+\begin{center}
+\begin{tikzpicture}[>=stealth',very thick,auto,
+                    every state/.style={minimum size=0pt,
+                    inner sep=2pt,draw=blue!50,very thick,fill=blue!20}]
+\only<1>{\node[state,initial]  (q_0)  {$q_0$};}
+\only<2->{\node[state,accepting]  (q_0)  {$q_0$};}
+\node[state] (q_1) [right=of q_0] {$q_1$};
+\node[state] (q_2) [below right=of q_0] {$q_2$};
+\node[state] (q_3) [right=of q_2] {$q_3$};
+\only<1>{\node[state, accepting] (q_4) [right=of q_1] {$q_4$};}
+\only<2->{\node[state, initial right] (q_4) [right=of q_1] {$q_4$};}
+\only<1-2>{
+\path[->] (q_0) edge node [above]  {\alert{$a$}} (q_1);
+\path[->] (q_1) edge node [above]  {\alert{$a$}} (q_4);
+\path[->] (q_4) edge [loop above] node  {\alert{$a, b$}} ();
+\path[->] (q_3) edge node [right]  {\alert{$a$}} (q_4);
+\path[->] (q_2) edge node [above]  {\alert{$a$}} (q_3);
+\path[->] (q_1) edge node [right]  {\alert{$b$}} (q_2);
+\path[->] (q_0) edge node [above]  {\alert{$b$}} (q_2);
+\path[->] (q_2) edge [loop left] node  {\alert{$b$}} ();
+\path[->] (q_3) edge [bend left=95, looseness=1.3] node [below]  {\alert{$b$}} (q_0);}
+\only<3->{
+\path[<-] (q_0) edge node [above]  {\alert{$a$}} (q_1);
+\path[<-] (q_1) edge node [above]  {\alert{$a$}} (q_4);
+\path[<-] (q_4) edge [loop above] node  {\alert{$a, b$}} ();
+\path[<-] (q_3) edge node [right]  {\alert{$a$}} (q_4);
+\path[<-] (q_2) edge node [above]  {\alert{$a$}} (q_3);
+\path[<-] (q_1) edge node [right]  {\alert{$b$}} (q_2);
+\path[<-] (q_0) edge node [above]  {\alert{$b$}} (q_2);
+\path[<-] (q_2) edge [loop left] node  {\alert{$b$}} ();
+\path[<-] (q_3) edge [bend left=95, looseness=1.3] node [below]  {\alert{$b$}} (q_0);}
+\end{tikzpicture}
+\end{center}
+\mbox{}\\[-18mm]
+
+\small
+\begin{itemize}
+\item<2-> exchange initial / accepting states\\[-2mm]
+\item<3-> reverse all edges\\[-2mm]
+\item<4-> subset construction $\Rightarrow$ DFA\\[-2mm]
+\item<5-> remove dead states\\[-2mm]
+\item<6-> repeat once more 
+          \onslide<6->{$\Rightarrow$ minimal DFA}
+\end{itemize}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+\frametitle{Regexps and Automata}
+
+\begin{center}
+\begin{tikzpicture}
+\node (rexp)  {\bl{\bf Regexps}};
+\node (nfa) [right=of rexp] {\bl{\bf NFAs}};
+\node (dfa) [right=of nfa] {\bl{\bf DFAs}};
+\onslide<1->{\node (mdfa) [right=of dfa] {\bl{\bf \begin{tabular}{c}minimal\\ DFAs\end{tabular}}};}
+\path[->, red, line width=2mm] (rexp) edge node [above=4mm, black] {\begin{tabular}{c@{\hspace{9mm}}}Thompson's\\[-1mm] construction\end{tabular}} (nfa);
+\path[->, red, line width=2mm] (nfa) edge node [above=4mm, black] {\begin{tabular}{c}subset\\[-1mm] construction\end{tabular}}(dfa);
+\onslide<1->{\path[->, red, line width=2mm] (dfa) edge node [below=9mm, black] {minimisation} (mdfa);}
 \onslide<2->{\path[->, red, line width=2mm] (dfa) edge [bend left=45] (rexp);}
 \end{tikzpicture}\\
 \end{center}
@@ -718,25 +1044,8 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
-\begin{frame}[c]
-\frametitle{\begin{tabular}{c}Regular Languages\end{tabular}}
-
-A language is \alert{regular} iff there exists
-a regular expression that recognises all its strings.\bigskip\medskip
-
-or {\bf equivalently}\bigskip\medskip
-
-A language is \alert{regular} iff there exists
-a deterministic finite automaton that recognises all its strings.\bigskip\medskip\pause
-
-Why is every finite set of strings a regular language?
-\end{frame}}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
 \begin{frame}<2>[c]
 \frametitle{DFA to Rexp}
 
@@ -761,12 +1070,10 @@
 
 \onslide<3>{How to get from a DFA to a regular expression?}
 
-\end{frame}}
+\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
 \begin{frame}[c]
 
 \begin{center}
@@ -796,11 +1103,10 @@
 \end{center}
 }
 
-\end{frame}}
+\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
 \begin{frame}[c]
 
 \begin{center}
@@ -837,13 +1143,48 @@
 \end{center}
 }
 
-\end{frame}}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+\frametitle{Regexps and Automata}
+
+\begin{center}
+\begin{tikzpicture}
+\node (rexp)  {\bl{\bf Regexps}};
+\node (nfa) [right=of rexp] {\bl{\bf NFAs}};
+\node (dfa) [right=of nfa] {\bl{\bf DFAs}};
+\onslide<1->{\node (mdfa) [right=of dfa] {\bl{\bf \begin{tabular}{c}minimal\\ DFAs\end{tabular}}};}
+\path[->, red, line width=2mm] (rexp) edge node [above=4mm, black] {\begin{tabular}{c@{\hspace{9mm}}}Thompson's\\[-1mm] construction\end{tabular}} (nfa);
+\path[->, red, line width=2mm] (nfa) edge node [above=4mm, black] {\begin{tabular}{c}subset\\[-1mm] construction\end{tabular}}(dfa);
+\onslide<1->{\path[->, red, line width=2mm] (dfa) edge node [below=9mm, black] {minimisation} (mdfa);}
+\onslide<1->{\path[->, red, line width=2mm] (dfa) edge [bend left=45] (rexp);}
+\end{tikzpicture}\\
+\end{center}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+\frametitle{Regular Languages (3)}
+
+A language is \alert{\bf regular} iff there exists a regular
+expression that recognises all its strings.\bigskip\medskip
+
+or {\bf equivalently}\bigskip\medskip
+
+A language is \alert{\bf regular} iff there exists a
+deterministic finite automaton that recognises all its
+strings.\bigskip\medskip\pause
+
+Why is every finite set of strings a regular language?
+\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
 \begin{frame}[c]
 
 Given the function 
@@ -872,7 +1213,7 @@
 \bl{$L(rev(r)) = Rev (L(r))$}
 \end{center}
 
-\end{frame}}
+\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%