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