# HG changeset patch # User Christian Urban # Date 1382480273 -3600 # Node ID 4725bba8ef261b84759d68ebcd2ff149de431547 # Parent 9da175d5eb63d07dc0d4ed39d81669ee05cfe37b added slides diff -r 9da175d5eb63 -r 4725bba8ef26 hws/hw04.pdf Binary file hws/hw04.pdf has changed diff -r 9da175d5eb63 -r 4725bba8ef26 hws/hw05.pdf Binary file hws/hw05.pdf has changed diff -r 9da175d5eb63 -r 4725bba8ef26 hws/hw05.tex --- a/hws/hw05.tex Mon Oct 21 15:02:54 2013 +0100 +++ b/hws/hw05.tex Tue Oct 22 23:17:53 2013 +0100 @@ -105,9 +105,17 @@ this automaton. (Hint: If you use Brzozwski's method, you can assume Arden's lemma which states that an equation of the form $q = q\cdot r + s$ has the unique solution $q = s \cdot r^*$.)\ + +\item Recall the definitions for $Der$ and $der$ from the lectures. +Prove by induction on $r$ the property that + +\[ +L(der\,c\,r) = Der\,c\,(L(r)) +\] + +holds. \end{enumerate} - \end{document} %%% Local Variables: diff -r 9da175d5eb63 -r 4725bba8ef26 progs/collatz.while --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/progs/collatz.while Tue Oct 22 23:17:53 2013 +0100 @@ -0,0 +1,8 @@ +write "Input a number "; +read n; +while n > 1 do { + if n % 2 == 0 + then n := n/2 + else n := 3*n+1; +}; +write "Yes"; diff -r 9da175d5eb63 -r 4725bba8ef26 progs/fib.while --- a/progs/fib.while Mon Oct 21 15:02:54 2013 +0100 +++ b/progs/fib.while Tue Oct 22 23:17:53 2013 +0100 @@ -1,15 +1,13 @@ -/* Fibonacci Program - input: n -*/ - -n := 19; -minus1 := 0; -minus2 := 1; +write "Input a number "; +read n; +x := 0; +y := 1; while n > 0 do { - temp := minus2; - minus2 := minus1 + minus2; - minus1 := temp; - n := n - 1 + temp := y; + y := x + y; + x := temp; + n := n - 1 }; -write minus2 +write "Result "; +write y diff -r 9da175d5eb63 -r 4725bba8ef26 slides/slides05.pdf Binary file slides/slides05.pdf has changed diff -r 9da175d5eb63 -r 4725bba8ef26 slides/slides05.tex --- a/slides/slides05.tex Mon Oct 21 15:02:54 2013 +0100 +++ b/slides/slides05.tex Tue Oct 22 23:17:53 2013 +0100 @@ -1,7 +1,7 @@ \documentclass[dvipsnames,14pt,t]{beamer} -\usepackage{beamerthemeplainculight} -\usepackage[T1]{fontenc} -\usepackage[latin1]{inputenc} +\usepackage{beamerthemeplaincu} +%\usepackage[T1]{fontenc} +%\usepackage[latin1]{inputenc} \usepackage{mathpartir} \usepackage[absolute,overlay]{textpos} \usepackage{ifthen} @@ -25,8 +25,13 @@ \definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords \definecolor{javadocblue}{rgb}{0.25,0.35,0.75} % javadoc +\makeatletter +\lst@CCPutMacro\lst@ProcessOther {"2D}{\lst@ttfamily{-{}}{-{}}} +\@empty\z@\@empty +\makeatother + \lstset{language=Java, - basicstyle=\ttfamily, + basicstyle=\consolas, keywordstyle=\color{javapurple}\bfseries, stringstyle=\color{javagreen}, commentstyle=\color{javagreen}, @@ -46,8 +51,8 @@ new,null,object,override,package,% private,protected,requires,return,sealed,% super,this,throw,trait,true,try,% - type,val,var,while,with,yield}, - otherkeywords={=>,<-,<\%,<:,>:,\#,@}, + type,val,var,while,with,yield, then}, + otherkeywords={=>,<-,<\%,<:,>:,\#,@,->}, sensitive=true, morecomment=[l]{//}, morecomment=[n]{/*}{*/}, @@ -57,7 +62,7 @@ } \lstset{language=Scala, - basicstyle=\ttfamily, + basicstyle=\consolas, keywordstyle=\color{javapurple}\bfseries, stringstyle=\color{javagreen}, commentstyle=\color{javagreen}, @@ -69,9 +74,10 @@ tabsize=2, showspaces=false, showstringspaces=false} + % beamer stuff -\renewcommand{\slidecaption}{AFL 05, King's College London, 24.~October 2012} +\renewcommand{\slidecaption}{AFL 05, King's College London, 23.~October 2013} \newcommand{\bl}[1]{\textcolor{blue}{#1}} \newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions @@ -91,7 +97,7 @@ \begin{center} \begin{tabular}{ll} Email: & christian.urban at kcl.ac.uk\\ - Of$\!$fice: & S1.27 (1st floor Strand Building)\\ + Office: & S1.27 (1st floor Strand Building)\\ Slides: & KEATS (also home work is there)\\ \end{tabular} \end{center} @@ -102,93 +108,209 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \mode{ -\begin{frame}[t] -\frametitle{\begin{tabular}{c}Deterministic Finite Automata\end{tabular}} - -A DFA \bl{$A(Q, q_0, F, \delta)$} consists of: +\begin{frame}[c] +\frametitle{DFA Minimisation} -\begin{itemize} -\item a finite 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$} -\item a transition function \bl{$\delta$} -\end{itemize}\pause +\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$} tests wether +\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 chance. +\item All unmarked pairs can be merged. +\end{enumerate} -\onslide<2->{ -\begin{center} -\begin{tabular}{l} -\bl{$\hat{\delta}(q, \texttt{""}) = q$}\\ -\bl{$\hat{\delta}(q, c\!::\!s) = \hat{\delta}(\delta(q, c), s)$} -\end{tabular} -\end{center}} +\end{frame}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\mode{ +\begin{frame}<1-2>[c] -\only<3,4>{ +\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=2, line width=0.5mm] - \node[state, initial] (q02) at ( 0,1) {$q_{0}$}; - \node[state] (q13) at ( 1,1) {$q_{1}$}; - \node[state, accepting] (q4) at ( 2,1) {$q_2$}; - \path[->] (q02) edge[bend left] node[above] {$a$} (q13) - (q13) edge[bend left] node[below] {$b$} (q02) - (q13) edge node[above] {$a$} (q4) - (q02) edge [loop below] node {$b$} () - (q4) edge [loop right] node {$a, b$} () - ; -\end{tikzpicture} -\end{center}}% -% -\only<5>{ -\begin{center} -\bl{$L(A) \dn \{ s \;|\; \hat{\delta}(q_0, s) \in F\}$} -\end{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}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \mode{ -\begin{frame}[t] -\frametitle{\begin{tabular}{c}Non-Deterministic\\[-1mm] Finite Automata\end{tabular}} - -An NFA \bl{$A(Q, q_0, F, \delta)$} consists again of: +\begin{frame}<1-2>[c] -\begin{itemize} -\item a finite set of states -\item one of these states is the start state -\item some states are accepting states -\item a transition \alert{relation}\medskip -\end{itemize} +\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{tabular}{c} -\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$}\\ -\end{tabular} -\end{center}\pause\medskip - -A string \bl{s} is accepted by an NFA, if there is a ``lucky'' sequence to an accepting state. +\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}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \mode{ \begin{frame}[c] -\frametitle{\begin{tabular}{c}Last Week\end{tabular}} -Last week I showed you\bigskip +\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} \begin{itemize} -\item an algorithm for automata minimisation - -\item an algorithm for transforming a regular expression into an NFA - -\item an algorithm for transforming an NFA into a DFA (subset construction) +\item<2-> exchange initial / accepting states +\item<3-> reverse all edges +\item<4-> subset construction $\Rightarrow$ DFA +\item<5-> repeat once more \onslide<6->{$\Rightarrow$ minimal DFA} \end{itemize} @@ -198,112 +320,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \mode{ \begin{frame}[c] -\frametitle{\begin{tabular}{c}This Week\end{tabular}} -Go over the algorithms again, but with two new things and \ldots\medskip - -\begin{itemize} -\item with the example: what is the regular expression that accepts every string, except those ending -in \bl{aa}?\medskip - -\item Go over the proof for \bl{$L(rev(r)) = Rev(L(r))$}.\medskip - -\item Anything else so far. -\end{itemize} - -\end{frame}} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\mode{ -\begin{frame}[c] -\frametitle{\begin{tabular}{c}Proofs By Induction\end{tabular}} - -\begin{itemize} -\item \bl{$P$} holds for \bl{$\varnothing$}, \bl{$\epsilon$} and \bl{c}\bigskip -\item \bl{$P$} holds for \bl{r$_1$ + r$_2$} under the assumption that \bl{$P$} already -holds for \bl{r$_1$} and \bl{r$_2$}.\bigskip -\item \bl{$P$} holds for \bl{r$_1$ $\cdot$ r$_2$} under the assumption that \bl{$P$} already -holds for \bl{r$_1$} and \bl{r$_2$}. -\item \bl{$P$} holds for \bl{r$^*$} under the assumption that \bl{$P$} already -holds for \bl{r}. -\end{itemize} - -\begin{center} -\bl{$P(r):\;\;L(rev(r)) = Rev(L(r))$} -\end{center} - -\end{frame}} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\mode{ -\begin{frame}[t] - -What is the regular expression that accepts every string, except those ending -in \bl{aa}?\pause\bigskip - -\begin{center} -\begin{tabular}{l} -\bl{(a + b)$^*$ba}\\ -\bl{(a + b)$^*$ab}\\ -\bl{(a + b)$^*$bb}\\\pause -\bl{a}\\ -\bl{\texttt{""}} -\end{tabular} -\end{center}\pause - -What are the strings to be avoided?\pause\medskip - -\begin{center} -\bl{(a + b)$^*$aa} -\end{center} - -\end{frame}} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\mode{ -\begin{frame}[t] - -An NFA for \bl{(a + b)$^*$aa} - -\begin{center} -\begin{tikzpicture}[scale=2, line width=0.5mm] - \node[state, initial] (q0) at ( 0,1) {$q_0$}; - \node[state] (q1) at ( 1,1) {$q_1$}; - \node[state, accepting] (q2) at ( 2,1) {$q_2$}; - \path[->] (q0) edge node[above] {$a$} (q1) - (q1) edge node[above] {$a$} (q2) - (q0) edge [loop below] node {$a$} () - (q0) edge [loop above] node {$b$} () - ; -\end{tikzpicture} -\end{center}\pause - -Minimisation for DFAs\\ -Subset Construction for NFAs - -\end{frame}} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\mode{ -\begin{frame}[c] -\frametitle{\begin{tabular}{c}DFA Minimisation\end{tabular}} - - -\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} tests wether -\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 nothing changed. -\item All unmarked pairs can be merged. -\end{enumerate} +\texttt{\consolas\lstinputlisting{../progs/fib.while}} \end{frame}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -312,120 +330,14 @@ \mode{ \begin{frame}[c] -Minimal DFA \only<1>{\bl{(a + b)$^*$aa}}\only<2->{\alert{not} \bl{(a + b)$^*$aa}} - -\begin{center} -\begin{tikzpicture}[scale=2, line width=0.5mm] - \only<1>{\node[state, initial] (q0) at ( 0,1) {$q_0$};} - \only<2->{\node[state, initial,accepting] (q0) at ( 0,1) {$q_0$};} - \only<1>{\node[state] (q1) at ( 1,1) {$q_1$};} - \only<2->{\node[state,accepting] (q1) at ( 1,1) {$q_1$};} - \only<1>{\node[state, accepting] (q2) at ( 2,1) {$q_2$};} - \only<2->{\node[state] (q2) at ( 2,1) {$q_2$};} - \path[->] (q0) edge[bend left] node[above] {$a$} (q1) - (q1) edge[bend left] node[above] {$b$} (q0) - (q2) edge[bend left=50] node[below] {$b$} (q0) - (q1) edge node[above] {$a$} (q2) - (q2) edge [loop right] node {$a$} () - (q0) edge [loop below] node {$b$} () - ; -\end{tikzpicture} -\end{center} - -\onslide<3>{How to get from a DFA to a regular expression?} +\texttt{\consolas\lstinputlisting{../progs/collatz.while}} \end{frame}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\mode{ -\begin{frame}[c] - -\begin{center} -\begin{tikzpicture}[scale=2, line width=0.5mm] - \only<1->{\node[state, initial] (q0) at ( 0,1) {$q_0$};} - \only<1->{\node[state] (q1) at ( 1,1) {$q_1$};} - \only<1->{\node[state] (q2) at ( 2,1) {$q_2$};} - \path[->] (q0) edge[bend left] node[above] {$a$} (q1) - (q1) edge[bend left] node[above] {$b$} (q0) - (q2) edge[bend left=50] node[below] {$b$} (q0) - (q1) edge node[above] {$a$} (q2) - (q2) edge [loop right] node {$a$} () - (q0) edge [loop below] node {$b$} () - ; -\end{tikzpicture} -\end{center}\pause\bigskip - -\onslide<2->{ -\begin{center} -\begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} -\bl{$q_0$} & \bl{$=$} & \bl{$2\, q_0 + 3 \,q_1 + 4\, q_2$}\\ -\bl{$q_1$} & \bl{$=$} & \bl{$2 \,q_0 + 3\, q_1 + 1\, q_2$}\\ -\bl{$q_2$} & \bl{$=$} & \bl{$1\, q_0 + 5\, q_1 + 2\, q_2$}\\ - -\end{tabular} -\end{center} -} - -\end{frame}} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\mode{ -\begin{frame}[c] - -\begin{center} -\begin{tikzpicture}[scale=2, line width=0.5mm] - \only<1->{\node[state, initial] (q0) at ( 0,1) {$q_0$};} - \only<1->{\node[state] (q1) at ( 1,1) {$q_1$};} - \only<1->{\node[state] (q2) at ( 2,1) {$q_2$};} - \path[->] (q0) edge[bend left] node[above] {$a$} (q1) - (q1) edge[bend left] node[above] {$b$} (q0) - (q2) edge[bend left=50] node[below] {$b$} (q0) - (q1) edge node[above] {$a$} (q2) - (q2) edge [loop right] node {$a$} () - (q0) edge [loop below] node {$b$} () - ; -\end{tikzpicture} -\end{center}\bigskip - -\onslide<2->{ -\begin{center} -\begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} -\bl{$q_0$} & \bl{$=$} & \bl{$\epsilon + q_0\,b + q_1\,b + q_2\,b$}\\ -\bl{$q_1$} & \bl{$=$} & \bl{$q_0\,a$}\\ -\bl{$q_2$} & \bl{$=$} & \bl{$q_1\,a + q_2\,a$}\\ - -\end{tabular} -\end{center} -} - -\onslide<3->{ -Arden's Lemma: -\begin{center} -If \bl{$q = q\,r + s$}\; then\; \bl{$q = s\, r^*$} -\end{center} -} - -\end{frame}} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\mode{ -\begin{frame}[c] -\frametitle{\begin{tabular}{c}Algorithms on Automata\end{tabular}} -\begin{itemize} -\item Reg $\rightarrow$ NFA: Thompson-McNaughton-Yamada method\medskip -\item NFA $\rightarrow$ DFA: Subset Construction\medskip -\item DFA $\rightarrow$ Reg: Brzozowski's Algebraic Method\medskip -\item DFA minimisation: Hopcrofts Algorithm\medskip -\item complement DFA -\end{itemize} -\end{frame}} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\qq}{\mbox{\texttt{"}}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \mode{