slides/slides07.tex
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sun, 01 Dec 2013 09:58:41 +0000
changeset 215 828303e8e4af
parent 188 12ef150273ce
child 302 0fa7b4221745
permissions -rw-r--r--
updated slides
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
\documentclass[dvipsnames,14pt,t]{beamer}
173
7cfb7a6f7c99 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
     2
\usepackage{beamerthemeplaincu}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
\usepackage[absolute,overlay]{textpos}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
\usepackage{ifthen}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
\usepackage{tikz}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
\usepackage{pgf}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
\usepackage{calc} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
\usepackage{ulem}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
\usepackage{courier}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
\usepackage{listings}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
\renewcommand{\uline}[1]{#1}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
\usetikzlibrary{arrows}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
\usetikzlibrary{automata}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
\usetikzlibrary{shapes}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
\usetikzlibrary{shadows}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
\usetikzlibrary{positioning}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
\usetikzlibrary{calc}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
\usetikzlibrary{plotmarks}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
\usepackage{graphicx} 
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
    20
\usepackage{pgfplots}
215
828303e8e4af updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 188
diff changeset
    21
\usepackage{../langs}
828303e8e4af updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 188
diff changeset
    22
\usepackage{../data}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
    24
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
% beamer stuff 
173
7cfb7a6f7c99 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    26
\renewcommand{\slidecaption}{AFL 07, King's College London, 13.~November 2013}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
\newcommand{\bl}[1]{\textcolor{blue}{#1}}       
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
\begin{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
\begin{frame}<1>[t]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
\frametitle{%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
  \begin{tabular}{@ {}c@ {}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
  \\[-3mm]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
  \LARGE Automata and \\[-2mm] 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
  \LARGE Formal Languages (7)\\[3mm] 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
  \end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
  \normalsize
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
  \begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
  \begin{tabular}{ll}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  Email:  & christian.urban at kcl.ac.uk\\
173
7cfb7a6f7c99 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    46
  Office: & S1.27 (1st floor Strand Building)\\
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
  Slides: & KEATS (also home work is there)\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
  \end{tabular}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
  \end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
\newcommand{\qq}{\mbox{\texttt{"}}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
\begin{frame}[c]
186
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    60
\frametitle{\begin{tabular}{c}Two Weeks Ago: CFGs\end{tabular}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
64
2d625418c011 added everything
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
    62
A \alert{context-free} grammar (CFG) \bl{$G$} consists of:
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
\begin{itemize}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
\item a finite set of nonterminal symbols (upper case)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
\item a finite terminal symbols or tokens (lower case)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
\item a start symbol (which must be a nonterminal)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
\item a set of rules
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
\begin{center}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    70
\bl{$A \rightarrow \text{rhs}_1 | \text{rhs}_2 | \ldots$}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
where \bl{rhs} are sequences involving terminals and nonterminals (can also be empty).\medskip\pause
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
\end{itemize}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
\begin{frame}[c]
186
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    84
\frametitle{\begin{tabular}{c}Hierarchy of Languages\end{tabular}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    86
Recall that languages are sets of strings.
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
\begin{center}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    89
\begin{tikzpicture}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    90
[rect/.style={draw=black!50, top color=white,bottom color=black!20, rectangle, very thick, rounded corners}]
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    91
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    92
\draw (0,0) node [rect, text depth=39mm, text width=68mm] {all languages};
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    93
\draw (0,-0.4) node [rect, text depth=28.5mm, text width=64mm] {decidable languages};
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    94
\draw (0,-0.85) node [rect, text depth=17mm] {context sensitive languages};
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    95
\draw (0,-1.14) node [rect, text depth=9mm, text width=50mm] {context-free languages};
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    96
\draw (0,-1.4) node [rect] {regular languages};
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    97
\end{tikzpicture}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    98
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
\mode<presentation>{
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   106
\begin{frame}[c]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   107
\frametitle{\begin{tabular}{c}Arithmetic Expressions\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   108
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   109
A grammar for arithmetic expressions and numbers:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   110
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   111
\begin{center}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   112
\bl{\begin{tabular}{lcl}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   113
$E$ & $\rightarrow$ &  $E \cdot + \cdot E \;|\;E \cdot * \cdot E \;|\;( \cdot E \cdot ) \;|\;N$ \\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   114
$N$ & $\rightarrow$ & $N \cdot N \;|\; 0 \;|\; 1 \;|\: \ldots \;|\; 9$ 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   115
\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   116
\end{center}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   117
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   118
Unfortunately it is left-recursive (and ambiguous).\medskip\\
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   119
A problem for \alert{recursive descent parsers} (e.g.~parser combinators).
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   120
\bigskip\pause
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   121
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   122
\end{frame}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   123
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   124
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   125
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   126
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   127
\mode<presentation>{
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   128
\begin{frame}[t]
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   129
\frametitle{\begin{tabular}{c}Numbers\end{tabular}}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   130
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   131
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   132
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   133
\begin{center}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   134
\bl{\begin{tabular}{lcl}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   135
$N$ & $\rightarrow$ &  $N \cdot N \;|\; 0 \;|\; 1 \;|\; \ldots \;|\; 9$\\
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   136
\end{tabular}}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   137
\end{center}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   138
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   139
A non-left-recursive, non-ambiguous grammar for numbers:
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   140
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   141
\begin{center}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   142
\bl{\begin{tabular}{lcl}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   143
$N$ & $\rightarrow$ &  $0 \cdot N \;|\;1 \cdot N \;|\;\ldots\;|\; 0 \;|\; 1 \;|\; \ldots \;|\; 9$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   144
\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   145
\end{center}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   146
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   147
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   148
\end{frame}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   149
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   150
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   151
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   152
\mode<presentation>{
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   153
\begin{frame}[c]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   154
\frametitle{\begin{tabular}{c}Operator Precedences\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   155
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   156
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   157
To disambiguate
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   158
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   159
\begin{center}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   160
\bl{\begin{tabular}{lcl}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   161
$E$ & $\rightarrow$ &  $E \cdot + \cdot E \;|\;E \cdot * \cdot E \;|\;( \cdot E \cdot ) \;|\;N$ \\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   162
\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   163
\end{center}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   164
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   165
Decide on how many precedence levels, say\medskip\\
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   166
\hspace{5mm}highest for \bl{$()$}, medium for \bl{*}, lowest for \bl{+}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   167
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   168
\begin{center}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   169
\bl{\begin{tabular}{lcl}
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   170
$E_{low}$ & $\rightarrow$ & $E_{med} \cdot + \cdot E_{low} \;|\; E_{med}$ \\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   171
$E_{med}$ & $\rightarrow$ & $E_{hi} \cdot * \cdot E_{med} \;|\; E_{hi}$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   172
$E_{hi}$ & $\rightarrow$ &  $( \cdot E_{low} \cdot ) \;|\;N$ \\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   173
\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   174
\end{center}\pause
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   175
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   176
\small What happens with \bl{$1 + 3  + 4$}?
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   177
\end{frame}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   178
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   179
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   180
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   181
\mode<presentation>{
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   182
\begin{frame}[c]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   183
\frametitle{\begin{tabular}{c}Removing Left-Recursion\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   184
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   185
The rule for numbers is directly left-recursive:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   186
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   187
\begin{center}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   188
\bl{\begin{tabular}{lcl}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   189
$N$ & $\rightarrow$ & $N \cdot N \;|\; 0 \;|\; 1\;\;\;\;(\ldots)$ 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   190
\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   191
\end{center}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   192
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   193
Translate
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   194
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   195
\begin{center}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   196
\begin{tabular}{ccc}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   197
\bl{\begin{tabular}{lcl}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   198
$N$ & $\rightarrow$ & $N \cdot \alpha$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   199
 &  $\;|\;$ & $\beta$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   200
 \\ 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   201
\end{tabular}} 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   202
& {\Large$\Rightarrow$} &
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   203
\bl{\begin{tabular}{lcl}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   204
$N$ & $\rightarrow$ & $\beta \cdot N'$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   205
$N'$ & $\rightarrow$ & $\alpha \cdot N'$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   206
 &  $\;|\;$ & $\epsilon$ 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   207
\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   208
\end{tabular}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   209
\end{center}\pause
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   210
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   211
Which means
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   212
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   213
\begin{center}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   214
\bl{\begin{tabular}{lcl}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   215
$N$ & $\rightarrow$ & $0 \cdot N' \;|\; 1 \cdot N'$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   216
$N'$ & $\rightarrow$ & $N \cdot N' \;|\; \epsilon$\\
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   217
\end{tabular}}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   218
\end{center}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   219
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   220
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   221
\end{frame}}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   222
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   223
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   224
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   225
\mode<presentation>{
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   226
\begin{frame}[c]
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   227
\frametitle{\begin{tabular}{c}Chomsky Normal Form\end{tabular}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   228
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   229
All rules must be of the form
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   230
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   231
\begin{center}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   232
\bl{$A \rightarrow a$}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   233
\end{center}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   234
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   235
or
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   236
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   237
\begin{center}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   238
\bl{$A \rightarrow B\cdot C$}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   239
\end{center}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   240
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   241
No rule can contain \bl{$\epsilon$}.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   242
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   243
\end{frame}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   244
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   245
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   246
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   247
\mode<presentation>{
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   248
\begin{frame}[c]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   249
\frametitle{\begin{tabular}{c}$\epsilon$-Removal\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   250
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   251
\begin{enumerate}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   252
\item If \bl{$A\rightarrow \alpha \cdot B \cdot \beta$} and \bl{$B \rightarrow \epsilon$} are in the grammar,
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   253
then add \bl{$A\rightarrow \alpha \cdot \beta$} (iterate if necessary).
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   254
\item Throw out all \bl{$B \rightarrow \epsilon$}.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   255
\end{enumerate}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   256
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   257
\small
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   258
\begin{center}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   259
\begin{tabular}{ccc}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   260
\bl{\begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   261
$N$ & $\rightarrow$ & $0 \cdot N' \;|\; 1\cdot N'$\\
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   262
$N'$ & $\rightarrow$ & $N \cdot N'\;|\;\epsilon$\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   263
\\ 
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   264
\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   265
\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   266
\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   267
\\
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   268
\end{tabular}} &
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   269
\bl{\begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l}
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   270
\\
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   271
$N$ & $\rightarrow$ & $0 \cdot N' \;|\; 1\cdot N'\;|\;0\;|\;1$\\
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   272
$N'$ & $\rightarrow$ & $N \cdot N'\;|\;N\;|\;\epsilon$\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   273
\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   274
$N$ & $\rightarrow$ & $0 \cdot N' \;|\; 1\cdot N'\;|\;0\;|\;1$\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   275
$N'$ & $\rightarrow$ & $N \cdot N'\;|\;N$\\
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   276
\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   277
\end{tabular}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   278
\end{center}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   279
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   280
\pause\normalsize
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   281
\begin{center}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   282
\bl{\begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   283
$N$ & $\rightarrow$ & $0 \cdot N\;|\; 1\cdot N\;|\;0\;|\;1$\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   284
\end{tabular}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   285
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   286
\end{center}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   287
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   288
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   289
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   290
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
   291
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   292
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   293
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   294
\begin{frame}[c]
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   295
\frametitle{\begin{tabular}{c}CYK Algorithm\end{tabular}}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   296
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   297
If grammar is in Chomsky normalform \ldots
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   298
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   299
\begin{center}
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   300
\bl{\begin{tabular}{@ {}lcl@ {}}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   301
$S$ & $\rightarrow$ &  $N\cdot P$ \\
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   302
$P$ & $\rightarrow$ &  $V\cdot N$ \\
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   303
$N$ & $\rightarrow$ &  $N\cdot N$ \\
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   304
$N$ & $\rightarrow$ &  $\texttt{students} \;|\; \texttt{Jeff} \;|\; \texttt{geometry} \;|\; \texttt{trains} $ \\
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   305
$V$ & $\rightarrow$ &  $\texttt{trains}$ 
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   306
\end{tabular}}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   307
\end{center}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   308
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   309
\bl{\texttt{Jeff trains geometry students}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   310
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   311
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   312
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   313
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   314
\mode<presentation>{
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   315
\begin{frame}[c]
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   316
\frametitle{\begin{tabular}{c}CYK Algorithm\end{tabular}}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   317
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   318
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   319
\begin{itemize}
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   320
\item fastest possible algorithm for recognition problem
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   321
\item runtime is \bl{$O(n^3)$}\bigskip
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   322
\item grammars need to be transferred into CNF
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   323
\end{itemize}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   324
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   325
\end{frame}}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   326
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   327
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   328
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   329
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   330
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   331
\begin{frame}[c]
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   332
\frametitle{\begin{tabular}{c}Hierarchy of Languages\end{tabular}}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   333
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   334
Recall that languages are sets of strings.
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   335
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   336
\begin{center}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   337
\begin{tikzpicture}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   338
[rect/.style={draw=black!50, top color=white,bottom color=black!20, rectangle, very thick, rounded corners}]
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   339
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   340
\draw (0,0) node [rect, text depth=39mm, text width=68mm] {all languages};
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   341
\draw (0,-0.4) node [rect, text depth=28.5mm, text width=64mm] {decidable languages};
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   342
\draw (0,-0.85) node [rect, text depth=17mm] {context sensitive languages};
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   343
\draw (0,-1.14) node [rect, text depth=9mm, text width=50mm] {context-free languages};
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   344
\draw (0,-1.4) node [rect] {regular languages};
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   345
\end{tikzpicture}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   346
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   347
\end{center}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   348
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   349
\end{frame}}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   350
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   351
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   352
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   353
\mode<presentation>{
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   354
\begin{frame}[c]
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   355
\frametitle{\begin{tabular}{c}Context Sensitive Grms\end{tabular}}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   356
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   357
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   358
\begin{center}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   359
\bl{\begin{tabular}{lcl}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   360
$S$ & $\Rightarrow$ &  $bSAA\;|\; \epsilon$\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   361
$A$ & $\Rightarrow$ & $a$\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   362
$bA$ & $\Rightarrow$ & $Ab$\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   363
\end{tabular}}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   364
\end{center}\pause
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   365
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   366
\begin{center}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   367
\bl{$S \Rightarrow\ldots\Rightarrow^? "ababaa"$}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   368
\end{center}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   369
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   370
\end{frame}}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   371
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   372
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   373
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   374
\mode<presentation>{
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   375
\begin{frame}[c]
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   376
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   377
\begin{center}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   378
\bl{\begin{tabular}{@{}lcl@{}}
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   379
\textit{Stmt} & $\rightarrow$ &  $\texttt{skip}$\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   380
              & $|$ & \textit{Id}\;\texttt{:=}\;\textit{AExp}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   381
              & $|$ & \texttt{if}\; \textit{BExp} \;\texttt{then}\; \textit{Block} \;\texttt{else}\; \textit{Block}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   382
              & $|$ & \texttt{while}\; \textit{BExp} \;\texttt{do}\; \textit{Block}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   383
              & $|$ & \texttt{read}\;\textit{Id}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   384
              & $|$ & \texttt{write}\;\textit{Id}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   385
              & $|$ & \texttt{write}\;\textit{String}\medskip\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   386
\textit{Stmts} & $\rightarrow$ &  \textit{Stmt} \;\texttt{;}\; \textit{Stmts}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   387
              & $|$ & \textit{Stmt}\medskip\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   388
\textit{Block} & $\rightarrow$ &  \texttt{\{}\,\textit{Stmts}\,\texttt{\}}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   389
                & $|$ & \textit{Stmt}\medskip\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   390
\textit{AExp} & $\rightarrow$ & \ldots\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   391
\textit{BExp} & $\rightarrow$ & \ldots\\
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   392
\end{tabular}}
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   393
\end{center}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   394
\end{frame}}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   395
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   396
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   397
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   398
\mode<presentation>{
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   399
\begin{frame}[c]
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   400
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   401
\mbox{\lstinputlisting[language=while]{../progs/fib.while}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   402
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   403
\end{frame}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   404
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   405
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   406
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   407
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   408
\mode<presentation>{
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   409
\begin{frame}[c]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   410
\frametitle{\begin{tabular}{c}An Interpreter\end{tabular}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   411
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   412
\begin{center}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   413
\bl{\begin{tabular}{l}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   414
$\{$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   415
\;\;$x := 5 \text{;}$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   416
\;\;$y := x * 3\text{;}$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   417
\;\;$y := x * 4\text{;}$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   418
\;\;$x := u * 3$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   419
$\}$
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   420
\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   421
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   422
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   423
\begin{itemize}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   424
\item the interpreter has to record the value of \bl{$x$} before assigning a value to \bl{$y$}\pause
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   425
\item \bl{\text{eval}(stmt, env)}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   426
\end{itemize}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   427
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   428
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   429
\end{frame}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   430
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   431
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   432
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   433
\mode<presentation>{
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   434
\begin{frame}[c]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   435
\frametitle{\begin{tabular}{c}Interpreter\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   436
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   437
\begin{center}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   438
\bl{\begin{tabular}{@{}lcl@{}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   439
$\text{eval}(n, E)$ & $\dn$ & $n$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   440
$\text{eval}(x, E)$ & $\dn$ & $E(x)$ \;\;\;\textcolor{black}{lookup \bl{$x$} in \bl{$E$}}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   441
$\text{eval}(a_1 + a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) + \text{eval}(a_2, E)$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   442
$\text{eval}(a_1 - a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) - \text{eval}(a_2, E)$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   443
$\text{eval}(a_1 * a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) * \text{eval}(a_2, E)$\bigskip\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   444
$\text{eval}(a_1 = a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) = \text{eval}(a_2, E)$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   445
$\text{eval}(a_1\,!\!= a_2, E)$ & $\dn$ & $\neg(\text{eval}(a_1, E) = \text{eval}(a_2, E))$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   446
$\text{eval}(a_1 < a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) < \text{eval}(a_2, E)$\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   447
\end{tabular}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   448
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   449
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   450
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   451
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   452
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   453
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   454
\begin{frame}[c]
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   455
\frametitle{\begin{tabular}{c}Interpreter (2)\end{tabular}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   456
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   457
\begin{center}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   458
\bl{\begin{tabular}{@{}lcl@{}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   459
$\text{eval}(\text{skip}, E)$ & $\dn$ & $E$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   460
$\text{eval}(x:=a, E)$ & $\dn$ & \bl{$E(x \mapsto \text{eval}(a, E))$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   461
\multicolumn{3}{@{}l@{}}{$\text{eval}(\text{if}\;b\;\text{then}\;cs_1\;\text{else}\;cs_2 , E) \dn$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   462
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)\;\text{then}\;
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   463
\text{eval}(cs_1,E)$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   464
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\phantom{\text{if}\;\text{eval}(b,E)\;}\text{else}\;\text{eval}(cs_2,E)$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   465
\multicolumn{3}{@{}l@{}}{$\text{eval}(\text{while}\;b\;\text{do}\;cs, E) \dn$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   466
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   467
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{then}\;
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   468
\text{eval}(\text{while}\;b\;\text{do}\;cs, \text{eval}(cs,E))$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   469
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   470
$\text{eval}(\text{write}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   471
\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   472
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   473
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   474
\end{frame}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   475
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   476
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   477
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   478
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   479
\mode<presentation>{
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   480
\begin{frame}[c]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   481
\frametitle{\begin{tabular}{c}Test Program\end{tabular}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   482
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   483
\mbox{}\\[-18mm]\mbox{}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   484
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   485
{\lstset{language=While}%%\fontsize{10}{12}\selectfont
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   486
\texttt{\lstinputlisting{../progs/loops.while}}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   487
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   488
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   489
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   490
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   491
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   492
\mode<presentation>{
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   493
\begin{frame}[t]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   494
\frametitle{\begin{tabular}{c}Interpreted Code\end{tabular}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   495
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   496
\begin{center}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   497
\begin{tikzpicture}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   498
\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   499
\addplot+[smooth] file {interpreted.data};
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   500
\end{axis}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   501
\end{tikzpicture}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   502
\end{center}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   503
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   504
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   505
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   506
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   507
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   508
\mode<presentation>{
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   509
\begin{frame}[c]
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   510
\frametitle{\begin{tabular}{c}Java Virtual Machine\end{tabular}}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   511
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   512
\begin{itemize}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   513
\item introduced in 1995
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   514
\item is a stack-based VM (like Postscript, CLR of .Net)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   515
\item contains a JIT compiler
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   516
\item many languages take advantage of JVM's infrastructure (JRE)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   517
\item is garbage collected $\Rightarrow$ no buffer overflows
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   518
\item some languages compile to the JVM: Scala, Clojure\ldots
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   519
\end{itemize}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   520
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   521
\end{frame}}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   522
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   523
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   524
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   525
\end{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   526
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   527
%%% Local Variables:  
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   528
%%% mode: latex
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   529
%%% TeX-master: t
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   530
%%% End: 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   531