--- a/slides/slides03.tex Wed Oct 09 20:54:52 2013 +0100
+++ b/slides/slides03.tex Fri Oct 11 14:02:35 2013 +0100
@@ -18,6 +18,8 @@
\usetikzlibrary{shadows}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
+\usetikzlibrary{fit}
+\usetikzlibrary{backgrounds}
\usepackage{graphicx}
\definecolor{javared}{rgb}{0.6,0,0} % for strings
@@ -436,9 +438,25 @@
\begin{frame}[c]
\begin{center}
-\includegraphics[scale=0.7]{pics/ch3.jpg}
+\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}\pause
+
\begin{itemize}
\item start can be an accepting state
\item it is possible that there is no accepting state
@@ -453,15 +471,30 @@
\begin{frame}[c]
\begin{center}
-\includegraphics[scale=0.7]{pics/ch3.jpg}
+\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}
for this automaton \bl{$\delta$} is the function\\
\begin{center}
\begin{tabular}{lll}
-\bl{(q$_0$, a) $\rightarrow$ q$_1$} & \bl{(q$_1$, a) $\rightarrow$ q$_4$} & \bl{(q$_4$, a) $\rightarrow$ q$_4$}\\
-\bl{(q$_0$, b) $\rightarrow$ q$_2$} & \bl{(q$_1$, b) $\rightarrow$ q$_2$} & \bl{(q$_4$, b) $\rightarrow$ q$_4$}\\
+\bl{$(q_0, a) \rightarrow q_1$} & \bl{$(q_1, a) \rightarrow q_4$} & \bl{$(q_4, a) \rightarrow q_4$}\\
+\bl{$(q_0, b) \rightarrow q_2$} & \bl{$(q_1, b) \rightarrow q_2$} & \bl{$(q_4, b) \rightarrow q_4$}\\
\end{tabular}\ldots
\end{center}
@@ -515,12 +548,12 @@
\begin{center}
\begin{tabular}{c}
-\bl{(q$_1$, a) $\rightarrow$ q$_2$}\\
-\bl{(q$_1$, a) $\rightarrow$ q$_3$}\\
+\bl{$(q_1, a) \rightarrow q_2$}\\
+\bl{$(q_1, a) \rightarrow q_3$}\\
\end{tabular}
\hspace{10mm}
\begin{tabular}{c}
-\bl{(q$_1$, $\epsilon$) $\rightarrow$ q$_2$}\\
+\bl{$(q_1, \epsilon) \rightarrow q_2$}\\
\end{tabular}
\end{center}
@@ -530,7 +563,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[c]
-\frametitle{An NFA}
+\frametitle{An NFA Example}
\begin{center}
\begin{tikzpicture}[scale=0.7,>=stealth',very thick,
@@ -549,12 +582,24 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[c]
+\frametitle{Rexp to NFA}
\begin{center}
-\begin{tabular}[b]{ll}
-\bl{$\varnothing$} & \includegraphics[scale=0.7]{pics/NULL.jpg}\\\\
-\bl{$\epsilon$} & \includegraphics[scale=0.7]{pics/epsilon.jpg}\\\\
-\bl{c} & \includegraphics[scale=0.7]{pics/char.jpg}\\
+\begin{tabular}[t]{l@{\hspace{10mm}}l}
+\raisebox{1mm}{\bl{$\varnothing$}} &
+\begin{tikzpicture}[scale=0.7,>=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},]
+\node[state, initial] (q_0) {$\mbox{}$};
+\end{tikzpicture}\\\\
+\raisebox{1mm}{\bl{$\epsilon$}} &
+\begin{tikzpicture}[scale=0.7,>=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},]
+\node[state, initial, accepting] (q_0) {$\mbox{}$};
+\end{tikzpicture}\\\\
+\raisebox{2mm}{\bl{$c$}} &
+\begin{tikzpicture}[scale=0.7,>=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},]
+\node[state, initial] (q_0) {$\mbox{}$};
+\node[state, accepting] (q_1) [right=of q_0] {$\mbox{}$};
+\path[->] (q_0) edge node [below] {\alert{$c$}} (q_1);
+\end{tikzpicture}\\\\
\end{tabular}
\end{center}
@@ -563,33 +608,102 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
-\begin{frame}[c]
+\begin{frame}[t]
+\frametitle{Case $r_1\cdot r_2$}
+
+\mbox{}\bigskip
+\onslide<1>{By recursion we are given two automata:\bigskip}
+
+\begin{tikzpicture}[node distance=3mm,
+ >=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},]
+\node[state, initial] (q_0) {$\mbox{}$};
+\node (r_1) [right=of q_0] {$\ldots$};
+\only<1>{
+\node[state, accepting] (t_1) [right=of r_1] {$\mbox{}$};
+\node[state, accepting] (t_2) [above=of t_1] {$\mbox{}$};
+\node[state, accepting] (t_3) [below=of t_1] {$\mbox{}$};}
+\only<2>{
+\node[state] (t_1) [right=of r_1] {$\mbox{}$};
+\node[state] (t_2) [above=of t_1] {$\mbox{}$};
+\node[state] (t_3) [below=of t_1] {$\mbox{}$};}
+\only<1>{\node[state, initial] (a_0) [right=2.5cm of t_1] {$\mbox{}$};}
+\only<2>{\node[state] (a_0) [right=2.5cm of t_1] {$\mbox{}$};}
+\node (b_1) [right=of a_0] {$\ldots$};
+\node[state, accepting] (c_1) [right=of b_1] {$\mbox{}$};
+\node[state, accepting] (c_2) [above=of c_1] {$\mbox{}$};
+\node[state, accepting] (c_3) [below=of c_1] {$\mbox{}$};
+\only<2>{
+\path[->] (t_1) edge node [above, pos=0.3] {\alert{$\epsilon$}} (a_0);
+\path[->] (t_2) edge node [above] {\alert{$\epsilon$}} (a_0);
+\path[->] (t_3) edge node [below] {\alert{$\epsilon$}} (a_0);
+}
+\begin{pgfonlayer}{background}
+\only<1>{\node (1) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (q_0) (r_1) (t_1) (t_2) (t_3)] {};}
+\only<1>{\node (2) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (a_0) (b_1) (c_1) (c_2) (c_3)] {};}
+\only<2>{\node (3) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (q_0) (c_1) (c_2) (c_3)] {};}
+\only<1>{\node [yshift=2mm] at (1.north) {\bl{$r_1$}};}
+\only<1>{\node [yshift=2mm] at (2.north) {\bl{$r_2$}};}
+\only<2>{\node [yshift=2mm] at (3.north) {\bl{$r_1\cdot r_2$}};}
+\end{pgfonlayer}
+\end{tikzpicture}\bigskip\bigskip
+
+\small
+We need to (1) change the accepting nodes of the first automaton into non-accepting nodes, and (2) connect them
+via $\epsilon$-transitions to the starting state of the second automaton.
-\begin{center}
-\begin{tabular}[t]{ll}
-\bl{r$_1$ $\cdot$ r$_2$} & \includegraphics[scale=0.6]{pics/seq.jpg}\\\\
-\end{tabular}
-\end{center}
+\end{frame}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\mode<presentation>{
+\begin{frame}[t]
+\frametitle{Case $r_1+ r_2$}
+
+\onslide<1>{By recursion we are given two automata:\smallskip}
+
+\begin{tikzpicture}[node distance=3mm,
+ >=stealth',very thick, every state/.style={minimum size=3pt,draw=blue!50,very thick,fill=blue!20},]
+\onslide<1>{\node at (0,0) (1) {$\mbox{}$};}
+\onslide<2>{\node at (0,0) [state, initial] (1) {$\mbox{}$};}
+\only<1>{
+\node[state, initial] (2) [above right=16mm of 1] {$\mbox{}$};
+\node[state, initial] (3) [below right=16mm of 1] {$\mbox{}$};}
+\only<2>{
+\node[state] (2) [above right=16mm of 1] {$\mbox{}$};
+\node[state] (3) [below right=16mm of 1] {$\mbox{}$};}
+\node (a) [right=of 2] {$\ldots$};
+\node[state, accepting] (a1) [right=of a] {$\mbox{}$};
+\node[state, accepting] (a2) [above=of a1] {$\mbox{}$};
+\node[state, accepting] (a3) [below=of a1] {$\mbox{}$};
+
+\node (b) [right=of 3] {$\ldots$};
+\node[state, accepting] (b1) [right=of b] {$\mbox{}$};
+\node[state, accepting] (b2) [above=of b1] {$\mbox{}$};
+\node[state, accepting] (b3) [below=of b1] {$\mbox{}$};
+\only<2>{
+\path[->] (1) edge node [above] {\alert{$\epsilon$}} (2);
+\path[->] (1) edge node [below] {\alert{$\epsilon$}} (3);
+}
+\begin{pgfonlayer}{background}
+\only<1>{\node (1) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (2) (a1) (a2) (a3)] {};}
+\only<1>{\node (2) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (3) (b1) (b2) (b3)] {};}
+\only<2>{\node (3) [rounded corners, inner sep=1mm, thick, draw=black!60, fill=black!20, fit= (1) (a2) (a3) (b2) (b3)] {};}
+\only<1>{\node [yshift=3mm] at (1.north) {\bl{$r_1$}};}
+\only<1>{\node [yshift=3mm] at (2.north) {\bl{$r_2$}};}
+\only<2>{\node [yshift=3mm] at (3.north) {\bl{$r_1+ r_2$}};}
+\end{pgfonlayer}
+\end{tikzpicture}
+
+\small
+We (1) need to introduce a new starting state and (2) connect it to the original two starting states.
\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[c]
-
-\begin{center}
-\begin{tabular}[t]{ll}
-\bl{r$_1$ + r$_2$} & \includegraphics[scale=0.7]{pics/alt.jpg}\\\\
-\end{tabular}
-\end{center}
-
-\end{frame}}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
-\begin{frame}[c]
+\frametitle{Rexp to NFA}
\begin{center}
\begin{tabular}[b]{ll}