slides/slides05.tex
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 23 Oct 2013 01:05:22 +0100
changeset 149 b728c9dbf120
parent 148 36eb7bfb0e63
child 150 a2d792ed768e
permissions -rw-r--r--
add

\documentclass[dvipsnames,14pt,t]{beamer}
\usepackage{beamerthemeplaincu}
%\usepackage[T1]{fontenc}
%\usepackage[latin1]{inputenc}
\usepackage{mathpartir}
\usepackage[absolute,overlay]{textpos}
\usepackage{ifthen}
\usepackage{tikz}
\usepackage{pgf}
\usepackage{calc} 
\usepackage{ulem}
\usepackage{courier}
\usepackage{listings}
\renewcommand{\uline}[1]{#1}
\usetikzlibrary{arrows}
\usetikzlibrary{automata}
\usetikzlibrary{shapes}
\usetikzlibrary{shadows}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usepackage{graphicx} 
\usepackage{pgfplots}

\definecolor{javared}{rgb}{0.6,0,0} % for strings
\definecolor{javagreen}{rgb}{0.25,0.5,0.35} % comments
\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=\consolas,
	keywordstyle=\color{javapurple}\bfseries,
	stringstyle=\color{javagreen},
	commentstyle=\color{javagreen},
	morecomment=[s][\color{javadocblue}]{/**}{*/},
	numbers=left,
	numberstyle=\tiny\color{black},
	stepnumber=1,
	numbersep=10pt,
	tabsize=2,
	showspaces=false,
	showstringspaces=false}

\lstdefinelanguage{scala}{
  morekeywords={abstract,case,catch,class,def,%
    do,else,extends,false,final,finally,%
    for,if,implicit,import,match,mixin,%
    new,null,object,override,package,%
    private,protected,requires,return,sealed,%
    super,this,throw,trait,true,try,%
    type,val,var,while,with,yield, then},
  otherkeywords={=>,<-,<\%,<:,>:,\#,@,->},
  sensitive=true,
  morecomment=[l]{//},
  morecomment=[n]{/*}{*/},
  morestring=[b]",
  morestring=[b]',
  morestring=[b]"""
}

\lstset{language=Scala,
	basicstyle=\consolas,
	keywordstyle=\color{javapurple}\bfseries,
	stringstyle=\color{javagreen},
	commentstyle=\color{javagreen},
	morecomment=[s][\color{javadocblue}]{/**}{*/},
	numbers=left,
	numberstyle=\tiny\color{black},
	stepnumber=1,
	numbersep=10pt,
	tabsize=2,
	showspaces=false,
	showstringspaces=false}
	
\begin{filecontents}{interpreted2.data}
%1 0.00503
200 1.005863
400 7.8296765
600 27.2321885
800 65.249271
1000 135.4493445
1200 232.134097
1400 382.527227
\end{filecontents}

\begin{filecontents}{compiled2.data}
200 0.222058
400 0.215204
600 0.202031
800 0.21986
1000 0.205934
1200 0.1981615
1400 0.207116
\end{filecontents}

% beamer stuff 
\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

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}<1>[t]
\frametitle{%
  \begin{tabular}{@ {}c@ {}}
  \\[-3mm]
  \LARGE Automata and \\[-2mm] 
  \LARGE Formal Languages (5)\\[3mm] 
  \end{tabular}}

  \normalsize
  \begin{center}
  \begin{tabular}{ll}
  Email:  & christian.urban at kcl.ac.uk\\
  Office: & S1.27 (1st floor Strand Building)\\
  Slides: & KEATS (also home work is there)\\
  \end{tabular}
  \end{center}


\end{frame}}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\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$} 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}

\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}<1-2>[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}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}<1-2>[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}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\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},]
\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<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}

\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[c]

\texttt{\consolas\lstinputlisting{../progs/fib.while}}

\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[c]

\texttt{\consolas\lstinputlisting{../progs/collatz.while}}

\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[c]

\texttt{\consolas\lstinputlisting{../progs/loops.while}}

\begin{textblock}{6}(10,2)
\begin{tikzpicture}[scale=0.46]
\begin{axis}[axis x line=bottom, axis y line=left, ylabel=secs,
    xlabel=n,
    enlargelimits=0.05,
    ybar interval=0.7, legend style=small]
\addplot file {interpreted2.data};
\addplot file {compiled2.data};
%\legend{interpreted, compiled}
\end{axis}
\end{tikzpicture}
\end{textblock}

\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\mode<presentation>{
\begin{frame}[t]

\consolas
\begin{center}
"if true then then 42 else +"
\end{center}


\begin{tabular}{@{}l}
KEYWORD: \\
\hspace{5mm}{if}, {then}, {else},\\ 
WHITESPACE:\\
\hspace{5mm}{" "}, {$\backslash$n},\\ 
IDENT:\\
\hspace{5mm}LETTER $\cdot$ (LETTER + DIGIT + {\_})$^*$\\ 
NUM:\\
\hspace{5mm}(NONZERODIGIT $\cdot$ DIGIT$^*$) + {0}\\
OP:\\
\hspace{5mm}{+}\\
COMMENT:\\
\hspace{5mm}{$\slash$*} $\cdot$ (ALL$^*$ $\cdot$ {*$\slash$} $\cdot$ ALL$^*$) $\cdot$ {*$\slash$}
\end{tabular}

\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[t]

\consolas
\begin{center}
"if true then then 42 else +"
\end{center}

\only<1>{
\small\begin{tabular}{l}
KEYWORD(if),\\ 
WHITESPACE,\\ 
IDENT(true),\\ 
WHITESPACE,\\ 
KEYWORD(then),\\ 
WHITESPACE,\\ 
KEYWORD(then),\\ 
WHITESPACE,\\ 
NUM(42),\\ 
WHITESPACE,\\ 
KEYWORD(else),\\ 
WHITESPACE,\\ 
OP(+)
\end{tabular}}

\only<2>{
\small\begin{tabular}{l}
KEYWORD(if),\\ 
IDENT(true),\\ 
KEYWORD(then),\\ 
KEYWORD(then),\\ 
NUM(42),\\ 
KEYWORD(else),\\ 
OP(+)
\end{tabular}}

\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[c]

\begin{tikzpicture}[scale=1]
  
  \draw[line width=1mm] (-.3, 0) rectangle (1.5,2);
  \draw (4.2,1) node {Code Gen};
  \draw (0.6,1.7) node {\footnotesize Parser};
  \draw (-2.7,1.7) node {\footnotesize Lexer};
  
  \draw[line width=1mm] (-1.8, 0) rectangle (-3.6,2);

  \draw[white] (1.7,1) node (X) {};
  \draw[white] (3.2,1) node (Y) {};
  \draw[red, ->, line width = 2mm] (X) -- (Y);
 
  \draw[red, <-, line width = 2mm] (-0.6,1) -- (-1.6,1);
  \draw[red, <-, line width = 2mm] (-3.8,1) -- (-4.8,1);
\end{tikzpicture}


\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[c]
\frametitle{\begin{tabular}{c}Two Rules\end{tabular}}

\begin{itemize}
\item Longest match rule (``maximal munch rule''): The 
longest initial substring matched by any regular expression is taken
as next token.\bigskip

\item Rule priority:
For a particular longest initial substring, the first regular
expression that can match determines the token.

\end{itemize}

%\url{http://www.technologyreview.com/tr10/?year=2011}
  
%finite deterministic automata/ nondeterministic automaton

%\item problem with infix operations, for example i-12


\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[t]
\frametitle{\begin{tabular}{c}Nullable\end{tabular}}

\small
\ldots{}whether a regular expression can match the empty string:
\begin{center}
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
\bl{$nullable(\varnothing)$}      & \bl{$\dn$} & \bl{$f\!\/alse$}\\
\bl{$nullable(\epsilon)$}           & \bl{$\dn$} &  \bl{$true$}\\
\bl{$nullable (c)$}                    & \bl{$\dn$} &  \bl{$f\!alse$}\\
\bl{$nullable (r_1 + r_2)$}       & \bl{$\dn$} &  \bl{$nullable(r_1) \vee nullable(r_2)$} \\ 
\bl{$nullable (r_1 \cdot r_2)$} & \bl{$\dn$} &  \bl{$nullable(r_1) \wedge nullable(r_2)$} \\
\bl{$nullable (r^*)$}                 & \bl{$\dn$} & \bl{$true$} \\
\end{tabular}
\end{center}

\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[c]
\frametitle{\begin{tabular}{c}Zeroable\end{tabular}}

\small
\ldots{}whether a regular expression can match nothing:
\begin{center}
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
\bl{$zeroable(\varnothing)$}      & \bl{$\dn$} & \bl{$true$}\\
\bl{$zeroable(\epsilon)$}           & \bl{$\dn$} &  \bl{$f\!alse$}\\
\bl{$zeroable (c)$}                    & \bl{$\dn$} &  \bl{$f\!alse$}\\
\bl{$zeroable (r_1 + r_2)$}       & \bl{$\dn$} &  \bl{$zeroable(r_1) \wedge zeroable(r_2)$} \\ 
\bl{$zeroable (r_1 \cdot r_2)$} & \bl{$\dn$} &  \bl{$zeroable(r_1) \vee zeroable(r_2)$} \\
\bl{$zeroable (r^*)$}                 & \bl{$\dn$} & \bl{$f\!alse$} \\
\end{tabular}
\end{center}


\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

\newcommand{\qq}{\mbox{\texttt{"}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[c]
\frametitle{\begin{tabular}{c}Grammars\end{tabular}}

\begin{center}
\bl{\begin{tabular}{lcl}
$E$ & $\rightarrow$ &  $F + (F \cdot \qq*\qq \cdot F) + (F \cdot \qq\backslash\qq \cdot F)$\\
$F$ & $\rightarrow$ & $T + (T \cdot \qq\texttt{+}\qq \cdot T) + (T \cdot \qq\texttt{-}\qq \cdot T)$\\
$T$ & $\rightarrow$ & $num + (\qq\texttt{(}\qq \cdot E \cdot \qq\texttt{)}\qq)$\\
\end{tabular}}
\end{center}

\bl{$E$}, \bl{$F$} and \bl{$T$} are non-terminals\\
\bl{$E$} is start symbol\\
\bl{$num$}, \bl{(}, \bl{)}, \bl{+} \ldots are terminals\bigskip\\


\bl{\texttt{(2*3)+(3+4)}}

\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>{
\begin{frame}[c]

\begin{center}
\bl{\begin{tabular}{lcl}
$E$ & $\rightarrow$ &  $F + (F \cdot \qq*\qq \cdot F) + (F \cdot \qq\backslash\qq \cdot F)$\\
$F$ & $\rightarrow$ & $T + (T \cdot \qq\texttt{+}\qq \cdot T) + (T \cdot \qq\texttt{-}\qq \cdot T)$\\
$T$ & $\rightarrow$ & $num + (\qq\texttt{(}\qq \cdot E \cdot \qq\texttt{)}\qq)$\\
\end{tabular}}
\end{center}

\begin{center}
\begin{tikzpicture}[level distance=8mm, blue]
  \node {E}
    child {node {F} 
     child {node {T} 
                 child {node {\qq(\qq\,E\,\qq)\qq}
                            child {node{F \qq*\qq{} F}
                                  child {node {T} child {node {2}}}
                                  child {node {T} child {node {3}}} 
                               }
                          }
              }
     child {node {\qq+\qq}}
     child {node {T}
       child {node {\qq(\qq\,E\,\qq)\qq} 
       child {node {F}
       child {node {T \qq+\qq{} T}
                    child {node {3}}
                    child {node {4}} 
                 }
                 }}
    }};
\end{tikzpicture}
\end{center}

\begin{textblock}{5}(1, 5)
\bl{\texttt{(2*3)+(3+4)}}
\end{textblock}

\end{frame}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   

\end{document}

%%% Local Variables:  
%%% mode: latex
%%% TeX-master: t
%%% End: