# HG changeset patch # User Christian Urban # Date 1450559483 0 # Node ID 2d0a59127694ee1e3bffa5e4f4f8af714fd0e622 # Parent f352cb238c32a9f9de689f4d600fbea77c9f003a updated diff -r f352cb238c32 -r 2d0a59127694 handouts/ho06.pdf Binary file handouts/ho06.pdf has changed diff -r f352cb238c32 -r 2d0a59127694 handouts/ho06.tex --- a/handouts/ho06.tex Mon Dec 07 17:50:05 2015 +0000 +++ b/handouts/ho06.tex Sat Dec 19 21:11:23 2015 +0000 @@ -37,10 +37,10 @@ to process from the input and the second is the unprocessed part of the input. As we shall see shortly, a parser combinator might return more than one such pair, the idea -being that there are potentially several ways how to interpret -the input. To simplify matters we will first look at the case -where the input to the parser combinators is just strings. As -a concrete example, consider the string +being that there are potentially several ways of how to +interpret the input. To simplify matters we will first look at +the case where the input to the parser combinators is just +strings. As a concrete example, consider the string \begin{center} \tt\Grid{iffoo\VS testbar} @@ -65,15 +65,14 @@ ``went wrong''\ldots or more precisely, nothing could be parsed. -The main attraction of parser combinators is that we can -easily build parser combinators out of smaller components -following very closely the structure of a grammar. In order to -implement this in an object-oriented programming language, -like Scala, we need to specify an abstract class for parser -combinators. This abstract class requires the implementation -of the function \texttt{parse} taking an argument of type -\texttt{I} and returns a set of type \mbox{\texttt{Set[(T, -I)]}}. +The idea of parser combinators is that we can easily build +parser combinators out of smaller components following very +closely the structure of a grammar. In order to implement this +in an object-oriented programming language, like Scala, we +need to specify an abstract class for parser combinators. This +abstract class requires the implementation of the function +\texttt{parse} taking an argument of type \texttt{I} and +returns a set of type \mbox{\texttt{Set[(T, I)]}}. \begin{center} \begin{lstlisting}[language=Scala] @@ -132,7 +131,7 @@ More interesting are the parser combinators that build larger parsers out of smaller component parsers. For example the alternative parser combinator is as follows: given two -parsers, say, $p$ and $q$, then we apply both parsers to the +parsers, say, $p$ and $q$, we apply both parsers to the input (remember parsers are functions) and combine the output (remember they are sets) @@ -194,7 +193,7 @@ \noindent We receive in the first two cases a successful output (that is a non-empty set). In each case, either -\pcode{a} or \pcode{b} are in the processed parts, and +\pcode{a} or \pcode{b} is in the processed part, and \pcode{c} in the unprocessed part. Clearly this parser cannot parse anything in the string \pcode{cc}, therefore the empty set. diff -r f352cb238c32 -r 2d0a59127694 progs/LOOP.j --- a/progs/LOOP.j Mon Dec 07 17:50:05 2015 +0000 +++ b/progs/LOOP.j Sat Dec 19 21:11:23 2015 +0000 @@ -2,13 +2,13 @@ .class public LOOP.LOOP .super java/lang/Object -.method public ()V +.method public : ()V aload_0 invokenonvirtual java/lang/Object/()V return .end method -.method public static write(I)V +.method public static write : (I)V .limit locals 5 .limit stack 5 iload 0 @@ -19,7 +19,7 @@ .end method -.method public static main([Ljava/lang/String;)V +.method public static main : ([Ljava/lang/String;)V .limit locals 200 .limit stack 200 diff -r f352cb238c32 -r 2d0a59127694 progs/token2.scala --- a/progs/token2.scala Mon Dec 07 17:50:05 2015 +0000 +++ b/progs/token2.scala Sat Dec 19 21:11:23 2015 +0000 @@ -225,7 +225,7 @@ // Lexing Rules for a Small While Language -val SYM = CRANGE("abcdefghijklmnopqrstuvwxyz") +val SYM = CRANGE("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") val DIGIT = CRANGE("0123456789") val ID = SYM ~ (SYM | DIGIT).% val NUM = PLUS(DIGIT) @@ -252,7 +252,7 @@ // filters out all white spaces def tokenise(r: Rexp, s: String) = - env(lexing_simp(r, s)).filterNot { (s) => s._1 == "w"}.mkString("\n") + env(lexing_simp(r, s)).filterNot { (s) => s._1 == "w"} // Testing //============ @@ -293,8 +293,13 @@ // Big Test //========== +def escape(raw: String): String = { + import scala.reflect.runtime.universe._ + Literal(Constant(raw)).toString +} + val prog2 = """ -write "fib"; +write "Fib"; read n; minus1 := 0; minus2 := 1; @@ -304,16 +309,155 @@ minus1 := temp; n := n - 1 }; -write "result"; +write "Result"; write minus2 """ +val prog3 = """ +start := 1000; +x := start; +y := start; +z := start; +while 0 < x do { + while 0 < y do { + while 0 < z do { + z := z - 1 + }; + z := start; + y := y - 1 + }; + y := start; + x := x - 1 +} +""" + + println("Tokens") -println(tokenise(WHILE_REGS, prog2)) +println(tokenise(WHILE_REGS, prog2).mkString("\n")) + +val fib_tokens = tokenise(WHILE_REGS, prog2) +fib_tokens.map{case (s1, s2) => (escape(s1), escape(s2))}.mkString(",\n") + +val test_tokens = tokenise(WHILE_REGS, prog3) +test_tokens.map{case (s1, s2) => (escape(s1), escape(s2))}.mkString(",\n") + + +/* for (i <- 1 to 120 by 10) { print(i.toString + ": ") time(lexing_simp(WHILE_REGS, prog2 * i)) } +*/ +val toks_fib = + List(("k","write"), + ("str","Fib"), + ("s",";"), + ("k","read"), + ("i","n"), + ("s",";"), + ("i","minus1"), + ("o",":="), + ("n","0"), + ("s",";"), + ("i","minus2"), + ("o",":="), + ("n","1"), + ("s",";"), + ("k","while"), + ("i","n"), + ("o",">"), + ("n","0"), + ("k","do"), + ("b","{"), + ("i","temp"), + ("o",":="), + ("i","minus2"), + ("s",";"), + ("i","minus2"), + ("o",":="), + ("i","minus1"), + ("o","+"), + ("i","minus2"), + ("s",";"), + ("i","minus1"), + ("o",":="), + ("i","temp"), + ("s",";"), + ("i","n"), + ("o",":="), + ("i","n"), + ("o","-"), + ("n","1"), + ("b","}"), + ("s",";"), + ("k","write"), + ("str","Result"), + ("s",";"), + ("k","write"), + ("i","minus2")) +val toks_test = + List(("i","start"), + ("o",":="), + ("n","1000"), + ("s",";"), + ("i","x"), + ("o",":="), + ("i","start"), + ("s",";"), + ("i","y"), + ("o",":="), + ("i","start"), + ("s",";"), + ("i","z"), + ("o",":="), + ("i","start"), + ("s",";"), + ("k","while"), + ("n","0"), + ("o","<"), + ("i","x"), + ("k","do"), + ("b","{"), + ("k","while"), + ("n","0"), + ("o","<"), + ("i","y"), + ("k","do"), + ("b","{"), + ("k","while"), + ("n","0"), + ("o","<"), + ("i","z"), + ("k","do"), + ("b","{"), + ("i","z"), + ("o",":="), + ("i","z"), + ("o","-"), + ("n","1"), + ("b","}"), + ("s",";"), + ("i","z"), + ("o",":="), + ("i","start"), + ("s",";"), + ("i","y"), + ("o",":="), + ("i","y"), + ("o","-"), + ("n","1"), + ("b","}"), + ("s",";"), + ("i","y"), + ("o",":="), + ("i","start"), + ("s",";"), + ("i","x"), + ("o",":="), + ("i","x"), + ("o","-"), + ("n","1"), + ("b","}")) diff -r f352cb238c32 -r 2d0a59127694 slides/slides12.pdf Binary file slides/slides12.pdf has changed diff -r f352cb238c32 -r 2d0a59127694 slides/slides12.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/slides/slides12.tex Sat Dec 19 21:11:23 2015 +0000 @@ -0,0 +1,547 @@ +\documentclass[dvipsnames,14pt,t]{beamer} +\usepackage{../slides} +\usepackage{../graphics} +\usepackage{../langs} +\usepackage{../data} +\usepackage{../grammar} + +% beamer stuff +\renewcommand{\slidecaption}{AFL, King's College London} +\newcommand{\bl}[1]{\textcolor{blue}{#1}} + + +\begin{document} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[t] +\frametitle{% + \begin{tabular}{@ {}c@ {}} + \\[-3mm] + \LARGE Automata and \\[-2mm] + \LARGE Formal Languages\\[3mm] + \end{tabular}} + + \normalsize + \begin{center} + \begin{tabular}{ll} + Email: & christian.urban at kcl.ac.uk\\ + Office: & S1.27 (1st floor Strand Building)\\ + Slides: & KEATS (also home work is there)\\ + \end{tabular} + \end{center} + +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c] + +\Large\bf There are more problems, than there are +programs.\bigskip\bigskip\pause\\ + +There must be a problem for which there is no program. +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c] +\frametitle{Subsets} + +\Large +If \bl{$A \subseteq B$} then \bl{$A$} has fewer elements +than \bl{$B$}\bigskip\bigskip + +\Large +\bl{$A \subseteq B$} and \bl{$B \subseteq A$}\bigskip + +then \bl{$A = B$} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \begin{frame}[c] + + \begin{center} + \begin{tikzpicture} + + \draw (-4,2.5) node [scale=2.5] (X) + {\begin{tabular}{l} + $\{$ + \!\includegraphics[scale=0.02]{../pics/o1.jpg}, + \includegraphics[scale=0.02]{../pics/o2.jpg}, + \!\includegraphics[scale=0.02]{../pics/o3.jpg}, + \includegraphics[scale=0.02]{../pics/o4.jpg}, + \!\includegraphics[scale=0.027]{../pics/o5.jpg} + $\}$ + \end{tabular}}; + + \draw (-5.6,-2.5) node [scale=2.5] (Y) + {\begin{tabular}{l} + $\{$ + \!\includegraphics[scale=0.059]{../pics/a1.jpg}, + \includegraphics[scale=0.048]{../pics/a2.jpg}, + \includegraphics[scale=0.02]{../pics/a3.jpg} + $\}$ + \end{tabular}}; + + \draw (0,1.5) node (X1) {5 elements}; + \draw (0,-3.5) node (y1) {3 elements}; + \end{tikzpicture} + \end{center} + + \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \begin{frame}[c] + \frametitle{Newton vs Feynman} + + \begin{center} + \begin{tabular}{cc} + \includegraphics[scale=0.2]{../pics/newton.jpg} & + \includegraphics[scale=0.2]{../pics/feynman.jpg}\\ + classical physics & quantum physics + \end{tabular} + \end{center} + \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \begin{frame}[c] + \frametitle{The Goal of the Talk} + \large + \begin{itemize} + \item show you that something very unintuitive happens with very large sets + \bigskip\bigskip + + \item convince you that there are more {\bf problems} than {\bf programs} + \end{itemize} + \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[t] +% + \begin{center} + \begin{tikzpicture} + + \draw (-5,2.5) node [scale=2.3] (X) + {\begin{tabular}{@ {\hspace{-3mm}}l} + \bl{$B$ $=$ $\{$ + \!\includegraphics[scale=0.02]{../pics/o1.jpg}, + \includegraphics[scale=0.02]{../pics/o2.jpg}, + \!\includegraphics[scale=0.02]{../pics/o3.jpg}, + \includegraphics[scale=0.02]{../pics/o4.jpg}, + \!\includegraphics[scale=0.027]{../pics/o5.jpg} + $\}$} + \end{tabular}}; + + \draw (-6.6,-0.5) node [scale=2.3] (Y) + {\begin{tabular}{@ {\hspace{-3mm}}l} + \bl{$A$ $=$ $\{$ + \!\includegraphics[scale=0.059]{../pics/a1.jpg}, + \includegraphics[scale=0.048]{../pics/a2.jpg}, + \includegraphics[scale=0.02]{../pics/a3.jpg} + $\}$} + \end{tabular}}; + + \only<1>{\draw (-5, -3) node[scale=2] + {\bl{$|A|$ $=$ $5$}, \bl{$|B|$ $=$ $3$}};} + \only<2>{ + \draw [->, line width=1mm, red] (-7.4, 0.2) -- (-6.1, 2.1); + \draw [->, line width=1mm, red] (-5.8, 0.2) -- (-3.1, 2.1); + \draw [->, line width=1mm, red] (-4.5, 0.2) -- (-7.6, 2.1); + \draw (-5, -3) node[scale=2] {then \bl{$|A|$ $\le$ $|B|$}}; + } + \only<3>{ + \draw [<-, line width=1mm, red] (-7.5, 0.2) -- (-6.1, 2.1); + \draw [<-, line width=1mm, red] (-7.3, 0.2) -- (-3.1, 2.1); + \draw [<-, line width=1mm, red] (-6, 0.2) -- (-7.5, 2.1); + \draw [<-, line width=1mm, red] (-4.5, 0.2) -- (-4.5, 2.1); + \draw [<-, line width=1mm, red] (-4.3, 0.2) -- (-1.3, 2.1); + + \draw (-5, -3) node[scale=1.5] {\small{}for \bl{$=$} + has to be a {\bf one-to-one} mapping}; + } + + + \end{tikzpicture} + \end{center} + +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c] +\frametitle{Cardinality} + +\Large +\bl{$|A|$} $\dn$ ``how many elements''\bigskip\\ + +\bl{$A \subseteq B \Rightarrow |A| \leq |B|$}\bigskip\\\pause + +if there is an injective function \bl{$f: A \rightarrow B$} then \bl{$|A| \leq |B|$}\ + +\begin{center} +\bl{\large$\forall x y.\; f(x) = f(y) \Rightarrow x = y$} +\end{center} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[t] + + \begin{center} + \begin{tikzpicture} + + \draw (-6.6,2.5) node [scale=2.3] (X) + {\begin{tabular}{@ {\hspace{-3mm}}l} + $A$ $=$ $\{$ + \!\includegraphics[scale=0.02]{../pics/o1.jpg}, + \includegraphics[scale=0.02]{../pics/o2.jpg}, + \!\includegraphics[scale=0.02]{../pics/o3.jpg} + $\}$ + \end{tabular}}; + + \draw (-6.6,-0.5) node [scale=2.3] (Y) + {\begin{tabular}{@ {\hspace{-3mm}}l} + $B$ $=$ $\{$ + \!\includegraphics[scale=0.059]{../pics/a1.jpg}, + \includegraphics[scale=0.048]{../pics/a2.jpg}, + \includegraphics[scale=0.02]{../pics/a3.jpg} + $\}$ + \end{tabular}}; + \onslide<3->{\draw (-7, -3) node[scale=1.5] + {then \bl{$|A|$ \alert{$=$} $|B|$}};} + \only<1>{ + \draw [->, line width=1mm, red] (-7.4, 0.2) -- (-6.1, 2.1); + \draw [->, line width=1mm, red] (-5.8, 0.2) -- (-4.3, 2.1); + \draw [->, line width=1mm, red] (-4.5, 0.2) -- (-7.6, 2.1); + } + \only<2->{ + \draw [<-, line width=1mm, blue] (-7.5, 0.2) -- (-7.5, 2.1); + \draw [<-, line width=1mm, blue] (-5.8, 0.2) -- (-4.3, 2.1); + \draw [<-, line width=1mm, blue] (-4.5, 0.2) -- (-6.1, 2.1); + } + + + \end{tikzpicture} + \end{center} + +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c] +\frametitle{Natural Numbers} + +\Large +\bl{$\mathbb{N}$} \bl{$\dn$} \bl{$\{0, 1, 2, 3, .......\}$}\bigskip\pause + +\bl{$A$} is \alert{countable} iff \bl{$|A| \leq |\mathbb{N}|$} + +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c] +\frametitle{First Question} + +\Large +\bl{$|\mathbb{N} - \{0\}| \;\;\;\alert{?}\;\;\; |\mathbb{N}| $}\bigskip\bigskip + +\large +\bl{$\geq$} or \bl{$\leq$} or \bl{$=$} ? +\bigskip\bigskip\bigskip\pause + +\bl{$x$ $\mapsto$ $x + 1$},\\ \bl{$|\mathbb{N} - \{0\}|$ $=$ +$|\mathbb{N}|$} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\mode{ +\begin{frame}[c] + +\Large +\bl{$|\mathbb{N} - \{0, 1\}| \;\;\;\alert{?}\;\;\; |\mathbb{N}| $}\bigskip\pause + +\bl{$|\mathbb{N} - \mathbb{O}| \;\;\;\alert{?}\;\;\; |\mathbb{N}| $}\bigskip\bigskip + +\normalsize +\bl{$\mathbb{O}$} $\dn$ odd numbers\quad \bl{$\{1,3,5......\}$}\\ \pause +\bl{$\mathbb{E}$} $\dn$ even numbers\quad \bl{$\{0,2,4......\}$}\\ +\end{frame}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\mode{ +\begin{frame}[c] + +\Large +\bl{$|\mathbb{N} \cup \mathbb{-N}| \;\;\;\alert{?}\;\;\; |\mathbb{N}| $}\bigskip\bigskip + + +\normalsize +\bl{$\mathbb{\phantom{-}N}$} $\dn$ positive numbers\quad \bl{$\{0,1,2,3,......\}$}\\ +\bl{$\mathbb{-N}$} $\dn$ negative numbers\quad \bl{$\{0,-1,-2,-3,......\}$}\\ +\end{frame}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\mode{ +\begin{frame}[c] + +\Large +\bl{$A$} is \alert{countable} if there exists an injective \bl{$f : A \rightarrow \mathbb{N}$}\bigskip + +\bl{$A$} is \alert{uncountable} if there does not exist an injective \bl{$f : A \rightarrow \mathbb{N}$}\bigskip\bigskip + + +countable: \bl{$|A| \leq |\mathbb{N}|$}\\ +uncountable: \bl{$|A| > |\mathbb{N}|$}\pause\bigskip + + +Does there exist such an \bl{$A$} ? + +\end{frame}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \mode{ + \begin{frame}[c] + \frametitle{Hilbert's Hotel} + + \begin{center} + \includegraphics[scale=0.8]{../pics/hilberts_hotel.jpg} + \end{center} + + \begin{itemize} + \item \ldots has as many rooms as there are natural numbers + \end{itemize} + + \end{frame}} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[t] + \frametitle{\begin{tabular}{c}Real Numbers between\\[-2mm] 0 and 1\end{tabular}} + + \begin{center} + \begin{tikzpicture} + \draw [fill, color=black!50] (1,4) rectangle (2, 3); + \draw [fill, color=black!50] (2,3) rectangle (3, 2); + \draw [fill, color=black!50] (3,2) rectangle (4, 1); + \draw [fill, color=black!50] (4,1) rectangle (5, 0); + \draw (0, 0) grid (8, 5); + \draw [line width = 1.mm] (1,0) -- (1, 5); + \draw [line width = 1.mm] (0, 4) -- (8, 4); + \draw (0.5,3.5) node {$1$}; + \draw (0.5,2.5) node {$2$}; + \draw (0.5,1.5) node {$3$}; + \draw (0.5,0.5) node {$4$}; + + \draw (1.5,3.5) node {\only<1>{$3$}\only<2->{$4$}}; + \draw (2.5,3.5) node {$3$}; + \draw (3.5,3.5) node {$3$}; + \draw (4.5,3.5) node {$3$}; + \draw (5.5,3.5) node {$3$}; + \draw (6.5,3.5) node {$3$}; + \draw (7.5,3.5) node {$\ldots$}; + + \draw (1.5,2.5) node {$1$}; + \draw (2.5,2.5) node {\only<1-2>{$2$}\only<3->{$3$}}; + \draw (3.5,2.5) node {$3$}; + \draw (4.5,2.5) node {$4$}; + \draw (5.5,2.5) node {$5$}; + \draw (6.5,2.5) node {$6$}; + \draw (7.5,2.5) node {$7$}; + + \draw (1.5,1.5) node {$0$}; + \draw (2.5,1.5) node {$1$}; + \draw (3.5,1.5) node {\only<1-3>{$0$}\only<4->{$1$}}; + \draw (4.5,1.5) node {$1$}; + \draw (5.5,1.5) node {$0$}; + \draw (6.5,1.5) node {$\ldots$}; + + \draw (1.5,0.5) node {$7$}; + \draw (2.5,0.5) node {$8$}; + \draw (3.5,0.5) node {$5$}; + \draw (4.5,0.5) node {\only<1-4>{$3$}\only<5->{$4$}}; + \draw (5.5,0.5) node {$9$}; + \draw (6.5,0.5) node {$\ldots$}; + + \draw (1.5,-0.5) node {$\ldots$}; + \draw (8.5,3.5) node {$\ldots$}; + \end{tikzpicture} + \end{center} + \mbox{}\\[-20mm]\mbox{} + + \onslide<6->{ + \begin{center} + \Large\bl{$|\mathbb{N}| < |R|$} + \end{center} + } + +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\mode{ +\begin{frame}[t] + \frametitle{The Set of Problems} + + $\aleph_0$ + + \begin{center} + \begin{tikzpicture} + \draw [fill, color=black!50] (1,4) rectangle (2, 3); + \draw [fill, color=black!50] (2,3) rectangle (3, 2); + \draw [fill, color=black!50] (3,2) rectangle (4, 1); + \draw [fill, color=black!50] (4,1) rectangle (5, 0); + \draw (0, 0) grid (8, 5); + \draw [line width = 1.mm] (1,0) -- (1, 5); + \draw [line width = 1.mm] (0, 4) -- (8, 4); + \draw (0.5,3.5) node {$1$}; + \draw (0.5,2.5) node {$2$}; + \draw (0.5,1.5) node {$3$}; + \draw (0.5,0.5) node {$4$}; + + \draw (1.5,4.5) node {$0$}; + \draw (2.5,4.5) node {$1$}; + \draw (3.5,4.5) node {$2$}; + \draw (4.5,4.5) node {$3$}; + \draw (5.5,4.5) node {$4$}; + \draw (6.5,4.5) node {$5$}; + \draw (7.5,4.5) node {$\ldots$}; + + \draw (1.5,3.5) node {$0$}; + \draw (2.5,3.5) node {$1$}; + \draw (3.5,3.5) node {$0$}; + \draw (4.5,3.5) node {$1$}; + \draw (5.5,3.5) node {$0$}; + \draw (6.5,3.5) node {$1$}; + \draw (7.5,3.5) node {$\ldots$}; + + \draw (1.5,2.5) node {$0$}; + \draw (2.5,2.5) node {$0$}; + \draw (3.5,2.5) node {$0$}; + \draw (4.5,2.5) node {$1$}; + \draw (5.5,2.5) node {$1$}; + \draw (6.5,2.5) node {$0$}; + \draw (7.5,2.5) node {$0$}; + + \draw (1.5,1.5) node {$0$}; + \draw (2.5,1.5) node {$0$}; + \draw (3.5,1.5) node {$0$}; + \draw (4.5,1.5) node {$0$}; + \draw (5.5,1.5) node {$0$}; + \draw (6.5,1.5) node {$\ldots$}; + + \draw (1.5,0.5) node {$1$}; + \draw (2.5,0.5) node {$1$}; + \draw (3.5,0.5) node {$0$}; + \draw (4.5,0.5) node {$1$}; + \draw (5.5,0.5) node {$1$}; + \draw (6.5,0.5) node {$\ldots$}; + + \draw (1.5,-0.5) node {$\ldots$}; + \draw (8.5,3.5) node {$\ldots$}; + + \end{tikzpicture} + \end{center} + + + \onslide<2>{ + \begin{center} + \large \bl{|Progs| $=$ $|\mathbb{N}|$ $<$ |Probs|} + \end{center} + } + + +\end{frame}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\mode{ +\begin{frame}[c] +\frametitle{Halting Problem} + +\large +Assume a program \bl{$H$} that decides for all programs \bl{$A$} and all +input data \bl{$D$} whether\bigskip + +\begin{itemize} +\item \bl{$H(A, D) \dn 1$} iff \bl{$A(D)$} terminates +\item \bl{$H(A, D) \dn 0$} otherwise +\end{itemize} + +\end{frame}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\mode{ +\begin{frame}[c] +\frametitle{Halting Problem (2)} + +\large +Given such a program \bl{$H$} define the following program \bl{$C$}: +for all programs \bl{$A$}\bigskip + +\begin{itemize} +\item \bl{$C(A) \dn 0$} iff \bl{$H(A, A) = 0$} +\item \bl{$C(A) \dn$ loops} otherwise +\end{itemize} + +\end{frame}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\mode{ +\begin{frame}[c] +\frametitle{Contradiction} + + +\bl{$H(C, C)$} is either \bl{$0$} or \bl{$1$}. + +\begin{itemize} +\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$} +\item \bl{$H(C, C) = 0$} $\stackrel{\text{def}\,H}{\Rightarrow}$ \bl{$C(C)$} loops $\stackrel{\text{def}\,C}{\Rightarrow}$\\ +\hspace{7cm}\bl{$H(C, C)=1$} +\end{itemize} + +Contradiction in both cases. So \bl{$H$} cannot exist. + +\end{frame}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \mode{ + \begin{frame}[c] + \frametitle{Take Home Points} + \large + + \begin{itemize} + \item there are sets that are more infinite than others\bigskip + \item even with the most powerful computer we can imagine, there + are problems that cannot be solved by any program\bigskip\bigskip + + \item in CS we actually hit quite often such problems (halting problem) + \end{itemize} + + \end{frame}} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\end{document} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: t +%%% End: +