slides/slides05.tex
changeset 798 aaf0bd0a211d
parent 796 c6f975266155
child 799 85267be9a5ed
equal deleted inserted replaced
797:ddcb616e036a 798:aaf0bd0a211d
   395   }
   395   }
   396   child {node {+}}
   396   child {node {+}}
   397   child {node {$\meta{E}$}
   397   child {node {$\meta{E}$}
   398     child[sibling distance=10mm] {node {$\meta{T}$}
   398     child[sibling distance=10mm] {node {$\meta{T}$}
   399       child {node {$\meta{F}$} child {node {2}}}
   399       child {node {$\meta{F}$} child {node {2}}}
   400       child {node {+}}
   400       child {node {*}}
   401       child {node {$\meta{T}$} child {node {$\meta{F}$} child {node {3}}}}
   401       child {node {$\meta{T}$} child {node {$\meta{F}$} child {node {3}}}}
   402     }
   402     }
   403     child {node {+}}
   403     child {node {+}}
   404     child {node {$\meta{E}$} child {node {$\meta{T}$}
   404     child {node {$\meta{E}$} child {node {$\meta{T}$}
   405         child {node {$\meta{F}$} child {node {4}}}}}
   405         child {node {$\meta{F}$} child {node {4}}}}}
   470 
   470 
   471 \bl{\texttt{if a then if x then y else c}}
   471 \bl{\texttt{if a then if x then y else c}}
   472 
   472 
   473 \end{frame}
   473 \end{frame}
   474 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
   474 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
       
   475 
       
   476 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   477 \begin{frame}[c]
       
   478 \frametitle{CYK Algorithm}
       
   479 
       
   480 Suppose the grammar:
       
   481 
       
   482 \begin{center}
       
   483 \bl{\begin{tabular}{@ {}lcl@ {}}
       
   484 $\meta{S}$ & $::=$ &  $\meta{N}\cdot \meta{P}$ \\
       
   485 $\meta{P}$ & $::=$ &  $\meta{V}\cdot \meta{N}$ \\
       
   486 $\meta{N}$ & $::=$ &  $\meta{N}\cdot \meta{N}$ \\
       
   487 $\meta{N}$ & $::=$ &  $\texttt{students} \;|\; \texttt{Jeff} \;|\; \texttt{geometry} \;|\; \texttt{trains} $ \\
       
   488 $\meta{V}$ & $::=$ &  $\texttt{trains}$ 
       
   489 \end{tabular}}
       
   490 \end{center}
       
   491 
       
   492 \bl{\texttt{Jeff trains geometry students}}
       
   493 
       
   494 \end{frame}
       
   495 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   496 
       
   497 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   498 \begin{frame}[c]
       
   499 \frametitle{CYK Algorithm}
       
   500 
       
   501 \begin{center}
       
   502   \begin{tikzpicture}[scale=1,line width=0.8mm]
       
   503   \draw (-2,0) -- (2,0);
       
   504   \draw (-2,1) -- (2,1);
       
   505   \draw (-2,2) -- (1,2);
       
   506   \draw (-2,3) -- (0,3);
       
   507   \draw (-2,4) -- (-1,4);
       
   508   
       
   509   \draw (0,0) -- (0, 3);
       
   510   \draw (1,0) -- (1, 2);
       
   511   \draw (2,0) -- (2, 1);
       
   512   \draw (-1,0) -- (-1, 4);
       
   513   \draw (-2,0) -- (-2, 4);
       
   514   
       
   515   \draw (-1.5,-0.5) node {\footnotesize{}\texttt{Jeff}}; 
       
   516   \draw (-0.5,-1.0) node {\footnotesize{}\texttt{trains}}; 
       
   517   \draw ( 0.5,-0.5) node {\footnotesize{}\texttt{geometry}}; 
       
   518   \draw ( 1.5,-1.0) node {\footnotesize{}\texttt{students}}; 
       
   519   
       
   520   \draw (-1.5,0.5) node {$N$}; 
       
   521   \draw (-0.5,0.5) node {$N,V$}; 
       
   522   \draw ( 0.5,0.5) node {$N$}; 
       
   523   \draw ( 1.5,0.5) node {$N$}; 
       
   524 
       
   525   \draw (-2.4, 3.5) node {$1$}; 
       
   526   \draw (-2.4, 2.5) node {$2$}; 
       
   527   \draw (-2.4, 1.5) node {$3$}; 
       
   528   \draw (-2.4, 0.5) node {$4$}; 
       
   529   \end{tikzpicture}
       
   530   \end{center}
       
   531 
       
   532 \begin{textblock}{5}(10,10)
       
   533 \small\bl{\begin{tabular}{@ {}lcl@ {}}
       
   534 $\meta{S}$ & $::=$ &  $\meta{N}\cdot \meta{P}$ \\
       
   535 $\meta{P}$ & $::=$ &  $\meta{V}\cdot \meta{N}$ \\
       
   536 $\meta{N}$ & $::=$ &  $\meta{N}\cdot \meta{N}$ \\
       
   537             $\meta{N}$ & $::=$ &  $\texttt{students} \;|\; \texttt{Jeff}$\\
       
   538             & & $\;|\; \texttt{geometry} \;|\; \texttt{trains} $ \\
       
   539 $\meta{V}$ & $::=$ &  $\texttt{trains}$ 
       
   540 \end{tabular}}  
       
   541 \end{textblock}
       
   542 
       
   543 \end{frame}
       
   544 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   545 
       
   546 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   547 \begin{frame}[t]
       
   548 \frametitle{Chomsky Normal Form}
       
   549 
       
   550 A grammar for palindromes over the alphabet~\bl{$\{a,b\}$}:
       
   551 
       
   552 \bl{\begin{plstx}[margin=0cm]
       
   553 : \meta{S} ::=  a\cdot \meta{S}\cdot a | b\cdot \meta{S}\cdot b | a\cdot a | b\cdot b | a | b \\
       
   554 \end{plstx}}
       
   555 
       
   556 \end{frame}
       
   557 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
   558 
       
   559 
       
   560 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   561 \begin{frame}[c]
       
   562 \frametitle{CYK Algorithm}
       
   563 
       
   564 
       
   565 \begin{itemize}
       
   566 \item fastest possible algorithm for recognition problem
       
   567 \item runtime is \bl{$O(n^3)$}\bigskip
       
   568 \item grammars need to be transformed into CNF
       
   569 \end{itemize}
       
   570 
       
   571 \end{frame}
       
   572 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
       
   573 
       
   574 
   475 
   575 
   476 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   576 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   477 \begin{frame}[c]
   577 \begin{frame}[c]
   478 \frametitle{Context Sensitive Grammars}
   578 \frametitle{Context Sensitive Grammars}
   479 
   579 
   917 \end{itemize}
  1017 \end{itemize}
   918 
  1018 
   919 \end{frame}}
  1019 \end{frame}}
   920 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  1020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   921 
  1021 
       
  1022 \begin{frame}[t,fragile]
       
  1023 \begin{mybox3}{}
       
  1024   For CW2, please include '$\backslash$' as a symbol in strings, because
       
  1025   the collatz program contains
       
  1026   \begin{lstlisting}[language=Scala, numbers=none]
       
  1027   write "\n";\end{lstlisting}  
       
  1028 \end{mybox3}
       
  1029 \end{frame}
       
  1030 
   922 \begin{frame}[t]
  1031 \begin{frame}[t]
   923 \begin{mybox3}{}
  1032 \begin{mybox3}{}
   924   val (r1s, f1s) = simp(r1)\\
  1033   val (r1s, f1s) = simp(r1)\\
   925   val (r2s, f2s) = simp(r2)\\
  1034   val (r2s, f2s) = simp(r2)\\
   926   how are the
  1035   how are the