author | Christian Urban <christian.urban@kcl.ac.uk> |
Mon, 03 Feb 2025 12:34:38 +0000 | |
changeset 978 | 8778d23fef92 |
parent 977 | 1e6eca42d90b |
permissions | -rw-r--r-- |
704 | 1 |
% !TEX program = xelatex |
744 | 2 |
\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer} |
315
470922b46a63
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
224
diff
changeset
|
3 |
\usepackage{../slides} |
215
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
4 |
\usepackage{../langs} |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
5 |
\usepackage{../data} |
871 | 6 |
\usepackage{../graphicss} |
315
470922b46a63
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
224
diff
changeset
|
7 |
\usepackage{soul} |
86
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
|
223
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
9 |
\tikzset{onslide/.code args={<#1>#2}{% |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
10 |
\only<#1>{\pgfkeysalso{#2}} % \pgfkeysalso doesn't change the path |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
11 |
}} |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
12 |
|
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
13 |
\makeatletter |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
14 |
\newenvironment<>{btHighlight}[1][] |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
15 |
{\begin{onlyenv}#2\begingroup\tikzset{bt@Highlight@par/.style={#1}}\begin{lrbox}{\@tempboxa}} |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
16 |
{\end{lrbox}\bt@HL@box[bt@Highlight@par]{\@tempboxa}\endgroup\end{onlyenv}} |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
17 |
|
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
18 |
\newcommand<>\btHL[1][]{% |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
19 |
\only#2{\begin{btHighlight}[#1]\bgroup\aftergroup\bt@HL@endenv}% |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
20 |
} |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
21 |
\def\bt@HL@endenv{% |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
22 |
\end{btHighlight}% |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
23 |
\egroup |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
24 |
} |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
25 |
\newcommand{\bt@HL@box}[2][]{% |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
26 |
\tikz[#1]{% |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
27 |
\pgfpathrectangle{\pgfpoint{1pt}{0pt}}{\pgfpoint{\wd #2}{\ht #2}}% |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
28 |
\pgfusepath{use as bounding box}% |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
29 |
\node[anchor=base west, fill=orange!30,outer sep=0pt,inner xsep=1pt, inner ysep=0pt, rounded corners=3pt, minimum height=\ht\strutbox+1pt,#1]{\raisebox{1pt}{\strut}\strut\usebox{#2}}; |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
30 |
}% |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
31 |
} |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
32 |
\makeatother |
e4b29b57f6a3
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
33 |
|
86
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
|
315
470922b46a63
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
224
diff
changeset
|
35 |
% beamer stuff |
459 | 36 |
\renewcommand{\slidecaption}{CFL 10, King's College London} |
86
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}} |
315
470922b46a63
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
224
diff
changeset
|
38 |
|
86
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
39 |
|
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
40 |
\begin{document} |
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
41 |
|
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
42 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
315
470922b46a63
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
224
diff
changeset
|
43 |
\begin{frame}[t] |
86
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
44 |
\frametitle{% |
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
\begin{tabular}{@ {}c@ {}} |
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
\\[-3mm] |
459 | 47 |
\LARGE Compilers and \\[-2mm] |
904 | 48 |
\LARGE Formal Languages\\[-3mm] |
86
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
49 |
\end{tabular}} |
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
50 |
|
904 | 51 |
\normalsize |
86
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
52 |
\begin{center} |
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
53 |
\begin{tabular}{ll} |
940 | 54 |
Email: & christian.urban at kcl.ac.uk\\ |
977 | 55 |
%%Office Hour: & Thurdays 15 -- 16\\ |
56 |
%%Location: & N7.07 (North Wing, Bush House)\\ |
|
57 |
Slides \& Progs: & KEATS\\ |
|
58 |
Emails: & I will try to stay on top of my inbox during Christmas\medskip\\ |
|
904 | 59 |
Pollev: & \texttt{\alert{https://pollev.com/cfltutoratki576}}\\ |
86
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
60 |
\end{tabular} |
904 | 61 |
\end{center} |
86
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
62 |
|
744 | 63 |
\begin{center} |
64 |
\begin{tikzpicture} |
|
65 |
\node[drop shadow,fill=white,inner sep=0pt] |
|
66 |
{\footnotesize\rowcolors{1}{capri!10}{white} |
|
67 |
\begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline |
|
68 |
1 Introduction, Languages & 6 While-Language \\ |
|
69 |
2 Regular Expressions, Derivatives & 7 Compilation, JVM \\ |
|
70 |
3 Automata, Regular Languages & 8 Compiling Functional Languages \\ |
|
71 |
4 Lexing, Tokenising & 9 Optimisations \\ |
|
72 |
5 Grammars, Parsing & \cellcolor{blue!50}10 LLVM \\ \hline |
|
73 |
\end{tabular}% |
|
74 |
}; |
|
75 |
\end{tikzpicture} |
|
76 |
\end{center} |
|
315
470922b46a63
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
224
diff
changeset
|
77 |
\end{frame} |
864 | 78 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
79 |
||
80 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
81 |
\tikzstyle{sensor}=[draw, fill=blue!20, text width=3.8em, line width=1mm, |
|
82 |
text centered, minimum height=2em,drop shadow] |
|
83 |
\tikzstyle{ann} = [above, text width=4em, text centered] |
|
84 |
\tikzstyle{sc} = [sensor, text width=7em, fill=red!20, |
|
85 |
minimum height=6em, rounded corners, drop shadow,line width=1mm] |
|
86 |
||
87 |
\begin{frame}[fragile,c] |
|
88 |
\frametitle{LLVM: Overview} |
|
89 |
||
90 |
\begin{tikzpicture} |
|
91 |
% Validation Layer is the same except that there are a set of nodes and links which are added |
|
92 |
||
93 |
\path (0,0) node (IR) [sc] {\textbf{LLVM-IR}\\ Optimisations}; |
|
94 |
\path (IR.west)+(-2.2,1.7) node (sou1) [sensor] {C++}; |
|
95 |
\path (IR.west)+(-2.2,0.5) node (sou2)[sensor] {C}; |
|
96 |
\path (IR.west)+(-2.2,-1.0) node (dots)[ann] {$\vdots$}; |
|
97 |
\path (IR.west)+(-2.2,-1.8) node (sou3)[sensor] {Haskell}; |
|
98 |
||
99 |
\path [draw,->,line width=1mm] (sou1.east) -- node [above] {} (IR.160); |
|
100 |
\path [draw,->,line width=1mm] (sou2.east) -- node [above] {} (IR.180); |
|
101 |
\path [draw,->,line width=1mm] (sou3.east) -- node [above] {} (IR.200); |
|
102 |
||
103 |
\path (IR.east)+(2.2,2.0) node (tar1)[sensor] {x86}; |
|
104 |
\path (IR.east)+(2.2,0.8) node (tar2)[sensor] {ARM}; |
|
105 |
\path (IR.east)+(2.2,-0.4) node (tar3)[sensor] {MIPS}; |
|
106 |
\path (IR.east)+(2.2,-1.6) node (tar4)[sensor] {RISC}; |
|
107 |
\path (IR.east)+(2.2,-2.8) node (tar5)[sensor] {Power PC}; |
|
108 |
\path (IR.east)+(2.2,-4.2) node (dots2)[ann] {$\vdots$}; |
|
109 |
||
110 |
\path [draw,<-,line width=1mm] (tar1.west) -- node [above] {} (IR.10); |
|
111 |
\path [draw,<-,line width=1mm] (tar2.west) -- node [above] {} (IR.5); |
|
112 |
\path [draw,<-,line width=1mm] (tar3.west) -- node [above] {} (IR.0); |
|
113 |
\path [draw,<-,line width=1mm] (tar4.west) -- node [above] {} (IR.-5); |
|
114 |
\path [draw,<-,line width=1mm] (tar5.west) -- node [above] {} (IR.-10); |
|
115 |
||
116 |
\end{tikzpicture} |
|
117 |
\end{frame} |
|
118 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
119 |
||
86
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
120 |
|
704 | 121 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
122 |
\begin{frame}[c,fragile] |
|
818 | 123 |
\frametitle{Static Single-Assignment} |
124 |
||
125 |
\bl{$(1 + a) + (3 + (b * 5))$}\bigskip\bigskip |
|
126 |
||
127 |
\begin{lstlisting}[language=LLVMIR,numbers=left] |
|
128 |
let tmp0 = add 1 a in |
|
129 |
let tmp1 = mul b 5 in |
|
130 |
let tmp2 = add 3 tmp1 in |
|
131 |
let tmp3 = add tmp0 tmp2 |
|
132 |
in tmp3 |
|
133 |
\end{lstlisting} |
|
134 |
||
135 |
||
136 |
\end{frame} |
|
137 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
138 |
||
139 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
140 |
\begin{frame}[c,fragile] |
|
141 |
\small |
|
142 |
||
143 |
\mbox{}\bigskip\bigskip\bigskip |
|
144 |
||
864 | 145 |
\begin{lstlisting}[language=llvm,numbers=left] |
818 | 146 |
define i32 @fact (i32 %n) { |
147 |
%tmp_20 = icmp eq i32 %n, 0 |
|
148 |
br i1 %tmp_20, label %if_branch_24, label %else_branch_25 |
|
149 |
if_branch_24: |
|
150 |
ret i32 1 |
|
151 |
else_branch_25: |
|
152 |
%tmp_22 = sub i32 %n, 1 |
|
153 |
%tmp_23 = call i32 @fact (i32 %tmp_22) |
|
154 |
%tmp_21 = mul i32 %n, %tmp_23 |
|
155 |
ret i32 %tmp_21 |
|
156 |
} |
|
157 |
\end{lstlisting} |
|
158 |
||
159 |
\begin{lstlisting}[language={},numbers=none] |
|
160 |
def fact(n) = if n == 0 then 1 else n * fact(n - 1) |
|
161 |
\end{lstlisting} |
|
162 |
\end{frame} |
|
163 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
164 |
||
864 | 165 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
166 |
\begin{frame}[fragile,c] |
|
167 |
\frametitle{LLVM Types} |
|
168 |
||
169 |
\tt |
|
170 |
\begin{center} |
|
171 |
\begin{tabular}{ll} |
|
172 |
boolean & i1 \\ |
|
173 |
byte & i8 \\ |
|
174 |
short & i16\\ |
|
175 |
char & i16\\ |
|
176 |
integer & i32\\ |
|
177 |
long & i64\\ |
|
178 |
float & float\\ |
|
179 |
double & double\\ |
|
180 |
*\_ & pointer to \\ |
|
181 |
**\_ & pointer to a pointer to\\ |
|
182 |
\mbox{}[\_] & arrays of\\ |
|
183 |
\end{tabular} |
|
184 |
\end{center} |
|
185 |
||
186 |
\end{frame} |
|
187 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
188 |
||
189 |
||
818 | 190 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
191 |
\begin{frame}[c,fragile] |
|
192 |
||
193 |
||
194 |
\begin{lstlisting}[language=LLVM,numbers=none] |
|
195 |
br i1 %var, label %if_br, label %else_br |
|
196 |
||
197 |
icmp eq i32 %x, %y ; for equal |
|
198 |
icmp sle i32 %x, %y ; signed less or equal |
|
199 |
icmp slt i32 %x, %y ; signed less than |
|
200 |
icmp ult i32 %x, %y ; unsigned less than |
|
201 |
||
202 |
%var = call i32 @foo(...args...) |
|
203 |
\end{lstlisting} |
|
204 |
||
205 |
\end{frame} |
|
206 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
207 |
||
864 | 208 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
209 |
\begin{frame}[fragile,c] |
|
210 |
\frametitle{Abstract Syntax Trees} |
|
211 |
\footnotesize |
|
212 |
||
213 |
\begin{lstlisting}[language=Scala,numbers=none,xleftmargin=-3mm] |
|
214 |
// Fun language (expressions) |
|
215 |
abstract class Exp |
|
216 |
abstract class BExp |
|
217 |
||
218 |
case class Call(name: String, args: List[Exp]) extends Exp |
|
219 |
case class If(a: BExp, e1: Exp, e2: Exp) extends Exp |
|
220 |
case class Write(e: Exp) extends Exp |
|
221 |
case class Var(s: String) extends Exp |
|
222 |
case class Num(i: Int) extends Exp |
|
223 |
case class Aop(o: String, a1: Exp, a2: Exp) extends Exp |
|
224 |
case class Sequence(e1: Exp, e2: Exp) extends Exp |
|
225 |
case class Bop(o: String, a1: Exp, a2: Exp) extends BExp |
|
226 |
\end{lstlisting} |
|
227 |
||
228 |
\end{frame} |
|
229 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
230 |
||
231 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
232 |
\begin{frame}[fragile,c] |
|
233 |
\frametitle{K-(Intermediate)Language} |
|
234 |
\footnotesize |
|
235 |
||
236 |
\begin{lstlisting}[language=Scala,numbers=none,xleftmargin=-3mm] |
|
237 |
abstract class KExp |
|
238 |
abstract class KVal |
|
239 |
||
240 |
// K-Values |
|
241 |
case class KVar(s: String) extends KVal |
|
242 |
case class KNum(i: Int) extends KVal |
|
243 |
case class Kop(o: String, v1: KVal, v2: KVal) extends KVal |
|
244 |
case class KCall(o: String, vrs: List[KVal]) extends KVal |
|
245 |
case class KWrite(v: KVal) extends KVal |
|
246 |
||
247 |
// K-Expressions |
|
248 |
case class KIf(x1: String, e1: KExp, e2: KExp) extends KExp |
|
249 |
case class KLet(x: String, v: KVal, e: KExp) extends KExp |
|
250 |
case class KReturn(v: KVal) extends KExp |
|
251 |
\end{lstlisting} |
|
252 |
||
253 |
\end{frame} |
|
254 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
255 |
||
256 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
257 |
\begin{frame}[fragile,c] |
|
258 |
\frametitle{KLet} |
|
259 |
||
260 |
\begin{lstlisting}[language=LLVM] |
|
261 |
tmp0 = add 1 a |
|
262 |
tmp1 = mul b 5 |
|
263 |
tmp2 = add 3 tmp1 |
|
264 |
tmp3 = add tmp0 tmp2 |
|
265 |
\end{lstlisting} |
|
266 |
||
267 |
\begin{lstlisting}[language=LLVMIR] |
|
268 |
KLet tmp0 , add 1 a in |
|
269 |
KLet tmp1 , mul b 5 in |
|
270 |
KLet tmp2 , add 3 tmp1 in |
|
271 |
KLet tmp3 , add tmp0 tmp2 in |
|
272 |
... |
|
273 |
\end{lstlisting} |
|
274 |
||
275 |
\begin{lstlisting}[language=Scala,numbers=none] |
|
276 |
case class KLet(x: String, e1: KVal, e2: KExp) |
|
277 |
\end{lstlisting} |
|
278 |
||
279 |
\end{frame} |
|
280 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
281 |
||
282 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
283 |
\begin{frame}[fragile,c] |
|
284 |
\frametitle{KLet} |
|
285 |
||
286 |
\begin{lstlisting}[language=LLVM] |
|
287 |
tmp0 = add 1 a |
|
288 |
tmp1 = mul b 5 |
|
289 |
tmp2 = add 3 tmp1 |
|
290 |
tmp3 = add tmp0 tmp2 |
|
291 |
\end{lstlisting} |
|
292 |
||
293 |
\begin{lstlisting}[language=LLVMIR] |
|
294 |
let tmp0 = add 1 a in |
|
295 |
let tmp1 = mul b 5 in |
|
296 |
let tmp2 = add 3 tmp1 in |
|
297 |
let tmp3 = add tmp0 tmp2 in |
|
298 |
... |
|
299 |
\end{lstlisting} |
|
300 |
||
301 |
\begin{lstlisting}[language=Scala,numbers=none] |
|
302 |
case class KLet(x: String, e1: KVal, e2: KExp) |
|
303 |
\end{lstlisting} |
|
304 |
||
305 |
\end{frame} |
|
306 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
307 |
||
308 |
||
309 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
310 |
\begin{frame}[fragile,c] |
|
311 |
\frametitle{CPS-Translation} |
|
312 |
\small |
|
313 |
||
314 |
\begin{lstlisting}[language=Scala,numbers=none] |
|
315 |
def CPS(e: Exp)(k: KVal => KExp) : KExp = |
|
316 |
e match { ... } |
|
317 |
\end{lstlisting} |
|
318 |
\bigskip\bigskip |
|
319 |
||
320 |
the continuation \texttt{k} can be thought of:\medskip |
|
321 |
||
322 |
\small |
|
323 |
\begin{lstlisting}[language=LLVMIR,numbers=none,xleftmargin=30mm,escapeinside={(*@}{@*)}] |
|
324 |
let tmp0 = add 1 a in |
|
325 |
let tmp1 = mul (*@$\Box$@*) 5 in |
|
326 |
let tmp2 = add 3 tmp1 in |
|
327 |
let tmp3 = add tmp0 tmp2 in |
|
328 |
KReturn tmp3 |
|
329 |
\end{lstlisting} |
|
330 |
||
331 |
\end{frame} |
|
332 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
333 |
||
334 |
||
335 |
||
818 | 336 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
337 |
\begin{frame}[c,fragile] |
|
704 | 338 |
|
339 |
||
340 |
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-6mm] |
|
341 |
def fact(n: Int) : Int = { |
|
342 |
if (n == 0) 1 else n * fact(n - 1) |
|
343 |
} |
|
344 |
||
345 |
||
346 |
def factC(n: Int, ret: Int => Int) : Int = { |
|
347 |
if (n == 0) ret(1) |
|
348 |
else factC(n - 1, x => ret(n * x)) |
|
349 |
} |
|
350 |
||
351 |
fact(10) |
|
352 |
factC(10, identity) |
|
353 |
\end{lstlisting} |
|
354 |
\end{frame} |
|
355 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
356 |
||
357 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
358 |
\begin{frame}[c,fragile] |
|
359 |
||
360 |
||
361 |
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-6mm] |
|
362 |
def fibC(n: Int, ret: Int => Int) : Int = { |
|
363 |
if (n == 0 || n == 1) ret(1) else |
|
364 |
fibC(n - 1, |
|
365 |
r1 => fibC(n - 2, |
|
366 |
r2 => ret(r1 + r2))) |
|
367 |
} |
|
368 |
||
369 |
fibC(10, identity) |
|
370 |
\end{lstlisting} |
|
371 |
\end{frame} |
|
372 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
373 |
||
904 | 374 |
\begin{frame}<1-15>[c] |
704 | 375 |
|
904 | 376 |
\end{frame} |
704 | 377 |
|
378 |
||
543 | 379 |
|
380 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
381 |
\begin{frame}[c] |
|
382 |
||
704 | 383 |
\Large\bf Are there more strings in \\ \hfill\bl{$L(a^*)$} or |
617 | 384 |
\bl{$L((a + b)^*)$}? |
543 | 385 |
|
386 |
\end{frame} |
|
387 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
388 |
||
389 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
390 |
\begin{frame}[c] |
|
704 | 391 |
\frametitle{Can you remember this HW?} |
392 |
||
393 |
\begin{itemize} |
|
394 |
\item (1) How many basic regular expressions are there to match |
|
395 |
the string \bl{$abcd$}? |
|
396 |
\item (2) How many if they cannot include |
|
397 |
\bl{$\ONE$} and \bl{$\ZERO$}? |
|
398 |
\item (3) How many if they are also not |
|
399 |
allowed to contain stars? |
|
400 |
\item (4) How many if they are also |
|
401 |
not allowed to contain \bl{$\_ + \_$}? |
|
402 |
\end{itemize} |
|
403 |
||
404 |
\end{frame} |
|
405 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
406 |
||
407 |
||
408 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
409 |
\begin{frame}[c] |
|
543 | 410 |
|
411 |
\Large\bf There are more problems, than there are |
|
412 |
programs.\bigskip\bigskip\pause\\ |
|
413 |
||
414 |
There must be a problem for which there is no program. |
|
415 |
\end{frame} |
|
416 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
417 |
||
418 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
419 |
\begin{frame}[c] |
|
420 |
\frametitle{Subsets} |
|
421 |
||
422 |
\Large |
|
423 |
If \bl{$A \subseteq B$} then \bl{$A$} has fewer or equal elements |
|
424 |
than \bl{$B$}\bigskip\bigskip |
|
425 |
||
426 |
\Large |
|
427 |
\bl{$A \subseteq B$} and \bl{$B \subseteq A$}\bigskip |
|
428 |
||
429 |
then \bl{$A = B$} |
|
430 |
\end{frame} |
|
431 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
432 |
||
433 |
||
434 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
435 |
\begin{frame}[c] |
|
436 |
||
437 |
\begin{center} |
|
438 |
\begin{tikzpicture} |
|
439 |
||
440 |
\draw (-4,2.5) node [scale=2.5] (X) |
|
441 |
{\begin{tabular}{l} |
|
442 |
$\{$ |
|
443 |
\!\includegraphics[scale=0.02]{../pics/o1.jpg}, |
|
444 |
\includegraphics[scale=0.02]{../pics/o2.jpg}, |
|
445 |
\!\includegraphics[scale=0.02]{../pics/o3.jpg}, |
|
446 |
\includegraphics[scale=0.02]{../pics/o4.jpg}, |
|
447 |
\!\includegraphics[scale=0.027]{../pics/o5.jpg} |
|
448 |
$\}$ |
|
449 |
\end{tabular}}; |
|
450 |
||
451 |
\draw (-5.6,-2.5) node [scale=2.5] (Y) |
|
452 |
{\begin{tabular}{l} |
|
453 |
$\{$ |
|
454 |
\!\includegraphics[scale=0.059]{../pics/a1.jpg}, |
|
455 |
\includegraphics[scale=0.048]{../pics/a2.jpg}, |
|
456 |
\includegraphics[scale=0.02]{../pics/a3.jpg} |
|
457 |
$\}$ |
|
458 |
\end{tabular}}; |
|
459 |
||
460 |
\draw (0,1.5) node (X1) {5 elements}; |
|
461 |
\draw (0,-3.5) node (y1) {3 elements}; |
|
462 |
\end{tikzpicture} |
|
463 |
\end{center} |
|
464 |
||
465 |
\end{frame} |
|
466 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
467 |
||
468 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
469 |
\begin{frame}[c] |
|
470 |
\frametitle{Newton vs Feynman} |
|
471 |
||
472 |
\begin{center} |
|
473 |
\begin{tabular}{cc} |
|
474 |
\includegraphics[scale=0.2]{../pics/newton.jpg} & |
|
475 |
\includegraphics[scale=0.2]{../pics/feynman.jpg}\\ |
|
476 |
classical physics & quantum physics |
|
477 |
\end{tabular} |
|
478 |
\end{center} |
|
479 |
\end{frame} |
|
480 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
481 |
||
482 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
483 |
\begin{frame}[c] |
|
484 |
\frametitle{The Goal of the Talk} |
|
485 |
\large |
|
486 |
\begin{itemize} |
|
487 |
\item show you that something very unintuitive happens with very large sets |
|
488 |
\bigskip\bigskip |
|
489 |
||
490 |
\item convince you that there are more {\bf problems} than {\bf programs} |
|
491 |
\end{itemize} |
|
492 |
\end{frame} |
|
493 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
494 |
||
495 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
496 |
\begin{frame}[t] |
|
497 |
% |
|
498 |
\begin{center} |
|
499 |
\begin{tikzpicture} |
|
500 |
||
501 |
\draw (-5,2.5) node [scale=2.3] (X) |
|
502 |
{\begin{tabular}{@ {\hspace{-3mm}}l} |
|
503 |
\bl{$B$ $=$ $\{$ |
|
504 |
\!\includegraphics[scale=0.02]{../pics/o1.jpg}, |
|
505 |
\includegraphics[scale=0.02]{../pics/o2.jpg}, |
|
506 |
\!\includegraphics[scale=0.02]{../pics/o3.jpg}, |
|
507 |
\includegraphics[scale=0.02]{../pics/o4.jpg}, |
|
508 |
\!\includegraphics[scale=0.027]{../pics/o5.jpg} |
|
509 |
$\}$} |
|
510 |
\end{tabular}}; |
|
511 |
||
512 |
\draw (-6.6,-0.5) node [scale=2.3] (Y) |
|
513 |
{\begin{tabular}{@ {\hspace{-3mm}}l} |
|
514 |
\bl{$A$ $=$ $\{$ |
|
515 |
\!\includegraphics[scale=0.059]{../pics/a1.jpg}, |
|
516 |
\includegraphics[scale=0.048]{../pics/a2.jpg}, |
|
517 |
\includegraphics[scale=0.02]{../pics/a3.jpg} |
|
518 |
$\}$} |
|
519 |
\end{tabular}}; |
|
520 |
||
521 |
\only<1>{\draw (-5, -3) node[scale=2] |
|
522 |
{\bl{$|A|$ $=$ $5$}, \bl{$|B|$ $=$ $3$}};} |
|
523 |
\only<2>{ |
|
524 |
\draw [->, line width=1mm, red] (-7.4, 0.2) -- (-6.1, 2.1); |
|
525 |
\draw [->, line width=1mm, red] (-5.8, 0.2) -- (-3.1, 2.1); |
|
526 |
\draw [->, line width=1mm, red] (-4.5, 0.2) -- (-7.6, 2.1); |
|
527 |
\draw (-5, -3) node[scale=2] {then \bl{$|A|$ $\le$ $|B|$}}; |
|
528 |
} |
|
529 |
\only<3>{ |
|
530 |
\draw [<-, line width=1mm, red] (-7.5, 0.2) -- (-6.1, 2.1); |
|
531 |
\draw [<-, line width=1mm, red] (-7.3, 0.2) -- (-3.1, 2.1); |
|
532 |
\draw [<-, line width=1mm, red] (-6, 0.2) -- (-7.5, 2.1); |
|
533 |
\draw [<-, line width=1mm, red] (-4.5, 0.2) -- (-4.5, 2.1); |
|
534 |
\draw [<-, line width=1mm, red] (-4.3, 0.2) -- (-1.3, 2.1); |
|
535 |
||
536 |
\draw (-5, -3) node[scale=1.5] {\small{}for \bl{$=$} |
|
537 |
has to be a {\bf one-to-one} mapping}; |
|
538 |
} |
|
539 |
||
540 |
||
541 |
\end{tikzpicture} |
|
542 |
\end{center} |
|
543 |
||
544 |
\end{frame} |
|
545 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
546 |
||
547 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
548 |
\begin{frame}[c] |
|
549 |
\frametitle{Cardinality} |
|
550 |
||
551 |
\Large |
|
552 |
\bl{$|A|$} $\dn$ ``how many elements''\bigskip\\ |
|
553 |
||
554 |
\bl{$A \subseteq B \Rightarrow |A| \leq |B|$}\bigskip\\\pause |
|
555 |
||
556 |
if there is an injective function \bl{$f: A \rightarrow B$} then \bl{$|A| \leq |B|$}\ |
|
557 |
||
558 |
\begin{center} |
|
559 |
\bl{\large$\forall x y.\; f(x) = f(y) \Rightarrow x = y$} |
|
560 |
\end{center} |
|
561 |
\end{frame} |
|
562 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
563 |
||
564 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
565 |
\begin{frame}[t] |
|
566 |
||
567 |
\begin{center} |
|
568 |
\begin{tikzpicture} |
|
569 |
||
570 |
\draw (-6.6,2.5) node [scale=2.3] (X) |
|
571 |
{\begin{tabular}{@ {\hspace{-3mm}}l} |
|
572 |
$A$ $=$ $\{$ |
|
573 |
\!\includegraphics[scale=0.02]{../pics/o1.jpg}, |
|
574 |
\includegraphics[scale=0.02]{../pics/o2.jpg}, |
|
575 |
\!\includegraphics[scale=0.02]{../pics/o3.jpg} |
|
576 |
$\}$ |
|
577 |
\end{tabular}}; |
|
578 |
||
579 |
\draw (-6.6,-0.5) node [scale=2.3] (Y) |
|
580 |
{\begin{tabular}{@ {\hspace{-3mm}}l} |
|
581 |
$B$ $=$ $\{$ |
|
582 |
\!\includegraphics[scale=0.059]{../pics/a1.jpg}, |
|
583 |
\includegraphics[scale=0.048]{../pics/a2.jpg}, |
|
584 |
\includegraphics[scale=0.02]{../pics/a3.jpg} |
|
585 |
$\}$ |
|
586 |
\end{tabular}}; |
|
587 |
\onslide<3->{\draw (-7, -3) node[scale=1.5] |
|
588 |
{then \bl{$|A|$ \alert{$=$} $|B|$}};} |
|
589 |
\only<1>{ |
|
590 |
\draw [->, line width=1mm, red] (-7.4, 0.2) -- (-6.1, 2.1); |
|
591 |
\draw [->, line width=1mm, red] (-5.8, 0.2) -- (-4.3, 2.1); |
|
592 |
\draw [->, line width=1mm, red] (-4.5, 0.2) -- (-7.6, 2.1); |
|
593 |
} |
|
594 |
\only<2->{ |
|
595 |
\draw [<-, line width=1mm, blue] (-7.5, 0.2) -- (-7.5, 2.1); |
|
596 |
\draw [<-, line width=1mm, blue] (-5.8, 0.2) -- (-4.3, 2.1); |
|
597 |
\draw [<-, line width=1mm, blue] (-4.5, 0.2) -- (-6.1, 2.1); |
|
598 |
} |
|
599 |
||
600 |
||
601 |
\end{tikzpicture} |
|
602 |
\end{center} |
|
603 |
||
604 |
\end{frame} |
|
605 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
315
470922b46a63
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
224
diff
changeset
|
606 |
|
86
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
607 |
|
543 | 608 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
609 |
\begin{frame}[c] |
|
610 |
\frametitle{Natural Numbers} |
|
611 |
||
612 |
\Large |
|
613 |
\bl{$\mathbb{N}$} \bl{$\dn$} \bl{$\{0, 1, 2, 3, .......\}$}\bigskip\pause |
|
614 |
||
615 |
\bl{$A$} is \alert{countable} iff \bl{$|A| \leq |\mathbb{N}|$} |
|
616 |
||
617 |
\end{frame} |
|
618 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
619 |
||
620 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
621 |
\begin{frame}[c] |
|
622 |
\frametitle{First Question} |
|
623 |
||
624 |
\Large |
|
625 |
\bl{$|\mathbb{N} - \{0\}| \;\;\;\alert{?}\;\;\; |\mathbb{N}| $}\bigskip\bigskip |
|
626 |
||
627 |
\large |
|
628 |
\bl{$\geq$} or \bl{$\leq$} or \bl{$=$} ? |
|
629 |
\bigskip\bigskip\bigskip\pause |
|
630 |
||
631 |
\bl{$x$ $\mapsto$ $x + 1$},\\ \bl{$|\mathbb{N} - \{0\}|$ $=$ |
|
632 |
$|\mathbb{N}|$} |
|
633 |
\end{frame} |
|
634 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
635 |
||
636 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
637 |
\mode<presentation>{ |
|
638 |
\begin{frame}[c] |
|
639 |
||
640 |
\Large |
|
641 |
\bl{$|\mathbb{N} - \{0, 1\}| \;\;\;\alert{?}\;\;\; |\mathbb{N}| $}\bigskip\pause |
|
642 |
||
643 |
\bl{$|\mathbb{N} - \mathbb{O}| \;\;\;\alert{?}\;\;\; |\mathbb{N}| $}\bigskip\bigskip |
|
644 |
||
645 |
\normalsize |
|
646 |
\bl{$\mathbb{O}$} $\dn$ odd numbers\quad \bl{$\{1,3,5......\}$}\\ \pause |
|
647 |
\bl{$\mathbb{E}$} $\dn$ even numbers\quad \bl{$\{0,2,4......\}$}\\ |
|
648 |
\end{frame}} |
|
649 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
650 |
||
651 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
652 |
\mode<presentation>{ |
|
653 |
\begin{frame}[c] |
|
654 |
||
655 |
\Large |
|
656 |
\bl{$|\mathbb{N} \cup \mathbb{-N}| \;\;\;\alert{?}\;\;\; |\mathbb{N}| $}\bigskip\bigskip |
|
657 |
||
658 |
||
659 |
\normalsize |
|
660 |
\bl{$\mathbb{\phantom{-}N}$} $\dn$ positive numbers\quad \bl{$\{0,1,2,3,......\}$}\\ |
|
661 |
\bl{$\mathbb{-N}$} $\dn$ negative numbers\quad \bl{$\{0,-1,-2,-3,......\}$}\\ |
|
662 |
\end{frame}} |
|
663 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
664 |
||
665 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
666 |
\mode<presentation>{ |
|
667 |
\begin{frame}[c] |
|
668 |
||
669 |
\Large |
|
670 |
\bl{$A$} is \alert{countable} if there exists an injective \bl{$f : A \rightarrow \mathbb{N}$}\bigskip |
|
671 |
||
672 |
\bl{$A$} is \alert{uncountable} if there does not exist an injective \bl{$f : A \rightarrow \mathbb{N}$}\bigskip\bigskip |
|
673 |
||
674 |
||
675 |
countable: \bl{$|A| \leq |\mathbb{N}|$}\\ |
|
676 |
uncountable: \bl{$|A| > |\mathbb{N}|$}\pause\bigskip |
|
677 |
||
678 |
||
679 |
Does there exist such an \bl{$A$} ? |
|
680 |
||
681 |
\end{frame}} |
|
682 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
683 |
||
684 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
685 |
\mode<presentation>{ |
|
686 |
\begin{frame}[c] |
|
687 |
\frametitle{Hilbert's Hotel} |
|
688 |
||
689 |
\begin{center} |
|
690 |
\includegraphics[scale=0.8]{../pics/hilberts_hotel.jpg} |
|
691 |
\end{center} |
|
692 |
||
693 |
\begin{itemize} |
|
694 |
\item \ldots has as many rooms as there are natural numbers |
|
695 |
\end{itemize} |
|
696 |
||
697 |
\end{frame}} |
|
698 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
699 |
||
700 |
||
701 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
702 |
\begin{frame}[t] |
|
703 |
\frametitle{\begin{tabular}{c}Real Numbers between\\[-2mm] 0 and 1\end{tabular}} |
|
704 |
||
705 |
\begin{center} |
|
706 |
\begin{tikzpicture} |
|
707 |
\draw [fill, color=black!50] (1,4) rectangle (2, 3); |
|
708 |
\draw [fill, color=black!50] (2,3) rectangle (3, 2); |
|
709 |
\draw [fill, color=black!50] (3,2) rectangle (4, 1); |
|
710 |
\draw [fill, color=black!50] (4,1) rectangle (5, 0); |
|
711 |
\draw (0, 0) grid (8, 5); |
|
712 |
\draw [line width = 1.mm] (1,0) -- (1, 5); |
|
713 |
\draw [line width = 1.mm] (0, 4) -- (8, 4); |
|
714 |
\draw (0.5,3.5) node {$1$}; |
|
715 |
\draw (0.5,2.5) node {$2$}; |
|
716 |
\draw (0.5,1.5) node {$3$}; |
|
717 |
\draw (0.5,0.5) node {$4$}; |
|
718 |
||
719 |
\draw (1.5,3.5) node {\only<1>{$3$}\only<2->{$4$}}; |
|
720 |
\draw (2.5,3.5) node {$3$}; |
|
721 |
\draw (3.5,3.5) node {$3$}; |
|
722 |
\draw (4.5,3.5) node {$3$}; |
|
723 |
\draw (5.5,3.5) node {$3$}; |
|
724 |
\draw (6.5,3.5) node {$3$}; |
|
725 |
\draw (7.5,3.5) node {$\ldots$}; |
|
726 |
||
727 |
\draw (1.5,2.5) node {$1$}; |
|
728 |
\draw (2.5,2.5) node {\only<1-2>{$2$}\only<3->{$3$}}; |
|
729 |
\draw (3.5,2.5) node {$3$}; |
|
730 |
\draw (4.5,2.5) node {$4$}; |
|
731 |
\draw (5.5,2.5) node {$5$}; |
|
732 |
\draw (6.5,2.5) node {$6$}; |
|
733 |
\draw (7.5,2.5) node {$7$}; |
|
734 |
||
735 |
\draw (1.5,1.5) node {$0$}; |
|
736 |
\draw (2.5,1.5) node {$1$}; |
|
737 |
\draw (3.5,1.5) node {\only<1-3>{$0$}\only<4->{$1$}}; |
|
738 |
\draw (4.5,1.5) node {$1$}; |
|
739 |
\draw (5.5,1.5) node {$0$}; |
|
740 |
\draw (6.5,1.5) node {$\ldots$}; |
|
741 |
||
742 |
\draw (1.5,0.5) node {$7$}; |
|
743 |
\draw (2.5,0.5) node {$8$}; |
|
744 |
\draw (3.5,0.5) node {$5$}; |
|
745 |
\draw (4.5,0.5) node {\only<1-4>{$3$}\only<5->{$4$}}; |
|
746 |
\draw (5.5,0.5) node {$9$}; |
|
747 |
\draw (6.5,0.5) node {$\ldots$}; |
|
748 |
||
749 |
\draw (1.5,-0.5) node {$\ldots$}; |
|
750 |
\draw (8.5,3.5) node {$\ldots$}; |
|
751 |
\end{tikzpicture} |
|
752 |
\end{center} |
|
753 |
\mbox{}\\[-20mm]\mbox{} |
|
754 |
||
755 |
\onslide<6->{ |
|
756 |
\begin{center} |
|
757 |
\Large\bl{$|\mathbb{N}| < |R|$} |
|
758 |
\end{center} |
|
759 |
} |
|
760 |
||
761 |
\end{frame} |
|
762 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
763 |
||
764 |
||
765 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
766 |
\mode<presentation>{ |
|
767 |
\begin{frame}[t] |
|
768 |
\frametitle{The Set of Problems} |
|
769 |
||
770 |
$\aleph_0$ |
|
771 |
||
772 |
\begin{center} |
|
773 |
\begin{tikzpicture} |
|
774 |
\draw [fill, color=black!50] (1,4) rectangle (2, 3); |
|
775 |
\draw [fill, color=black!50] (2,3) rectangle (3, 2); |
|
776 |
\draw [fill, color=black!50] (3,2) rectangle (4, 1); |
|
777 |
\draw [fill, color=black!50] (4,1) rectangle (5, 0); |
|
778 |
\draw (0, 0) grid (8, 5); |
|
779 |
\draw [line width = 1.mm] (1,0) -- (1, 5); |
|
780 |
\draw [line width = 1.mm] (0, 4) -- (8, 4); |
|
781 |
\draw (0.5,3.5) node {$1$}; |
|
782 |
\draw (0.5,2.5) node {$2$}; |
|
783 |
\draw (0.5,1.5) node {$3$}; |
|
784 |
\draw (0.5,0.5) node {$4$}; |
|
785 |
||
786 |
\draw (1.5,4.5) node {$0$}; |
|
787 |
\draw (2.5,4.5) node {$1$}; |
|
788 |
\draw (3.5,4.5) node {$2$}; |
|
789 |
\draw (4.5,4.5) node {$3$}; |
|
790 |
\draw (5.5,4.5) node {$4$}; |
|
791 |
\draw (6.5,4.5) node {$5$}; |
|
792 |
\draw (7.5,4.5) node {$\ldots$}; |
|
793 |
||
794 |
\draw (1.5,3.5) node {$0$}; |
|
795 |
\draw (2.5,3.5) node {$1$}; |
|
796 |
\draw (3.5,3.5) node {$0$}; |
|
797 |
\draw (4.5,3.5) node {$1$}; |
|
798 |
\draw (5.5,3.5) node {$0$}; |
|
799 |
\draw (6.5,3.5) node {$1$}; |
|
800 |
\draw (7.5,3.5) node {$\ldots$}; |
|
801 |
||
802 |
\draw (1.5,2.5) node {$0$}; |
|
803 |
\draw (2.5,2.5) node {$0$}; |
|
804 |
\draw (3.5,2.5) node {$0$}; |
|
805 |
\draw (4.5,2.5) node {$1$}; |
|
806 |
\draw (5.5,2.5) node {$1$}; |
|
807 |
\draw (6.5,2.5) node {$0$}; |
|
808 |
\draw (7.5,2.5) node {$0$}; |
|
809 |
||
810 |
\draw (1.5,1.5) node {$0$}; |
|
811 |
\draw (2.5,1.5) node {$0$}; |
|
812 |
\draw (3.5,1.5) node {$0$}; |
|
813 |
\draw (4.5,1.5) node {$0$}; |
|
814 |
\draw (5.5,1.5) node {$0$}; |
|
815 |
\draw (6.5,1.5) node {$\ldots$}; |
|
816 |
||
817 |
\draw (1.5,0.5) node {$1$}; |
|
818 |
\draw (2.5,0.5) node {$1$}; |
|
819 |
\draw (3.5,0.5) node {$0$}; |
|
820 |
\draw (4.5,0.5) node {$1$}; |
|
821 |
\draw (5.5,0.5) node {$1$}; |
|
822 |
\draw (6.5,0.5) node {$\ldots$}; |
|
823 |
||
824 |
\draw (1.5,-0.5) node {$\ldots$}; |
|
825 |
\draw (8.5,3.5) node {$\ldots$}; |
|
826 |
||
827 |
\end{tikzpicture} |
|
828 |
\end{center} |
|
829 |
||
830 |
||
831 |
\onslide<2>{ |
|
832 |
\begin{center} |
|
833 |
\large \bl{|Progs| $=$ $|\mathbb{N}|$ $<$ |Probs|} |
|
834 |
\end{center} |
|
835 |
} |
|
836 |
||
837 |
||
838 |
\end{frame}} |
|
839 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
840 |
||
841 |
||
842 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
843 |
\mode<presentation>{ |
|
844 |
\begin{frame}[c] |
|
845 |
\frametitle{Halting Problem} |
|
846 |
||
847 |
\large |
|
848 |
Assume a program \bl{$H$} that decides for all programs \bl{$A$} and all |
|
849 |
input data \bl{$D$} whether\bigskip |
|
850 |
||
851 |
\begin{itemize} |
|
852 |
\item \bl{$H(A, D) \dn 1$} iff \bl{$A(D)$} terminates |
|
853 |
\item \bl{$H(A, D) \dn 0$} otherwise |
|
854 |
\end{itemize} |
|
855 |
||
856 |
\end{frame}} |
|
857 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
858 |
||
859 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
860 |
\mode<presentation>{ |
|
861 |
\begin{frame}[c] |
|
862 |
\frametitle{Halting Problem (2)} |
|
863 |
||
864 |
\large |
|
865 |
Given such a program \bl{$H$} define the following program \bl{$C$}: |
|
866 |
for all programs \bl{$A$}\bigskip |
|
867 |
||
868 |
\begin{itemize} |
|
869 |
\item \bl{$C(A) \dn 0$} iff \bl{$H(A, A) = 0$} |
|
870 |
\item \bl{$C(A) \dn$ loops} otherwise |
|
871 |
\end{itemize} |
|
872 |
||
873 |
\end{frame}} |
|
874 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
875 |
||
876 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
877 |
\mode<presentation>{ |
|
878 |
\begin{frame}[c] |
|
879 |
\frametitle{Contradiction} |
|
880 |
||
881 |
||
882 |
\bl{$H(C, C)$} is either \bl{$0$} or \bl{$1$}. |
|
883 |
||
884 |
\begin{itemize} |
|
885 |
\item \bl{$H(C, C) = 1$} $\stackrel{\text{def}\,H}{\Rightarrow}$ \bl{$C(C)\downarrow$} $\stackrel{\text{def}\,C}{\Rightarrow}$ \bl{$H(C, C)=0$} |
|
886 |
\item \bl{$H(C, C) = 0$} $\stackrel{\text{def}\,H}{\Rightarrow}$ \bl{$C(C)$} loops $\stackrel{\text{def}\,C}{\Rightarrow}$\\ |
|
887 |
\hspace{7cm}\bl{$H(C, C)=1$} |
|
888 |
\end{itemize} |
|
889 |
||
890 |
Contradiction in both cases. So \bl{$H$} cannot exist. |
|
891 |
||
892 |
\end{frame}} |
|
893 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
894 |
||
895 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
896 |
\mode<presentation>{ |
|
897 |
\begin{frame}[c] |
|
898 |
\frametitle{Take Home Points} |
|
899 |
\large |
|
900 |
||
901 |
\begin{itemize} |
|
902 |
\item there are sets that are more infinite than others\bigskip |
|
903 |
\item even with the most powerful computer we can imagine, there |
|
904 |
are problems that cannot be solved by any program\bigskip\bigskip |
|
905 |
||
906 |
\item in CS we actually hit quite often such problems (halting problem) |
|
907 |
\end{itemize} |
|
908 |
||
909 |
\end{frame}} |
|
910 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
864 | 911 |
|
912 |
\begin{frame}<1-20>[c] |
|
913 |
\end{frame} |
|
914 |
||
915 |
||
959
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
916 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
917 |
\begin{frame}[c] |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
918 |
\frametitle{Big Thank You!} |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
919 |
\large |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
920 |
|
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
921 |
\only<1>{% |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
922 |
\begin{itemize} |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
923 |
\item<-1> It is always fun to learn new things in CFL |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
924 |
\item<-1> I want to add Higher-Order Functions and Algebraic Datatypes |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
925 |
to Fun |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
926 |
\end{itemize}} |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
927 |
|
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
928 |
\only<2->{% |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
929 |
\begin{itemize} |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
930 |
\item<2-> Thanks for ALL the EoY feedback:\medskip\bigskip |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
931 |
|
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
932 |
\begin{minipage}{13cm} |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
933 |
\begin{quote}\it |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
934 |
``If all modules were as good as this one I would start recommending KCL over basically every single university instead of suggesting people look somewhere else.'' |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
935 |
\end{quote} |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
936 |
\end{minipage} |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
937 |
\end{itemize}} |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
938 |
|
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
939 |
\hfill\includegraphics[scale=0.12]{thanks.png} |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
940 |
|
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
941 |
\end{frame} |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
942 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
943 |
|
64ec1884d860
updated and added pascal.while file
Christian Urban <christian.urban@kcl.ac.uk>
parents:
940
diff
changeset
|
944 |
|
86
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
945 |
\end{document} |
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
946 |
|
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
947 |
%%% Local Variables: |
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
948 |
%%% mode: latex |
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
949 |
%%% TeX-master: t |
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
950 |
%%% End: |
6a7fe83820c8
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
951 |