\documentclass{beamer}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tipa}
\usepackage{mathrsfs}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage[normalem]{ulem}
\usetikzlibrary{calc,decorations.markings,positioning,arrows.meta}

\tikzset{->-/.style={decoration={
  markings,
  mark=at position #1 with {\arrow{>}}},postaction={decorate}}}
  
\author{Tom Cuchta}
\title{}
\mode<presentation> {
\usetheme{Warsaw}
\setbeamertemplate{navigation symbols}{}
}
\begin{document}

\begin{frame}{}
20 April 2017
\end{frame}

\begin{frame}{Peano Arithmetic}
\begin{enumerate}
\item $(\forall x)\neg (0 = Sx)$ 
\item $(\forall x)(\forall y)(Sx=Sy \rightarrow x=y)$ 
\item $(\forall y)(y=0 \vee (\exists x)(Sx=y))$ 
\item $(\forall x)(x+0=x)$ 
\item $(\forall x)(\forall y)(x+Sy=S(x+y))$
\item $(\forall x)(x \cdot 0=0)$ 
\item $(\forall x)(\forall y)(x \cdot Sy=(x\cdot y)+x)$
\item (Induction schema) For any predicate $Px$, the following is an axiom:
$$\left( P(0) \wedge (\forall x)(Px \rightarrow P(Sx)) \right) \rightarrow (\forall y)(Py).$$
%\item $(\forall x)(\forall y)(x+y=y+x)$ 
%\item $(\forall x)(\forall y)(x \cdot y = y \cdot x)$
\end{enumerate}
\end{frame}

\begin{frame}{Consistency and completeness}
A theory is called \underline{consistent} if it does \textbf{not} derive a contradiction. A theory is called \underline{complete} if every sentence (or its negation) has a proof in that theory (i.e. nothing is ``undecidable"). \\
\vspace{1cm}
Is Peano arithmetic consistent? Is it complete?
\end{frame}

\begin{frame}{Iteration -- Fibonacci sequence}
Most generally, the word \textit{recursion} captures the idea of self-reference and repetition. \\
\textit{Example:} The Fibonacci sequence is often defined ``iteratively" (with a ``recurrence relation"):
$$(*) \hspace{35pt} F(n+1) \stackrel{\mathrm{def}}{=} F(n)+F(n-1); F(0)=1, F(1)=1.$$
The numbers $F(0)=1$ and $F(1)=1$ are the ``initial conditions". To find the value of $F(2)$, simply plug in $n=1$ into $(*)$ to arrive at:
$$F(2)=F(1)+F(0)=1+1=2.$$
To find $F(3)$ plug in $n=2$ into $(*)$ to get
$$F(3)=F(2)+F(1)=2+1=3.$$
etc...
$$F(4)=F(3)+F(2)=3+2=5.$$
\end{frame}

\begin{frame}{Recursion -- Factorial}
The factorial function is $n!=n(n-1)(n-2)\ldots(2)(1)$. For example,
$$4!=4 \cdot 3 \cdot 2 \cdot 1 = 24.$$
It can also be defined recursively (we write $\mathrm{fac}$ for simplicity):
$$\mathrm{fac}(n+1)=(n+1) \cdot \mathrm{fac}(n); \mathrm{fac}(1)=1.$$
This definition shows that
$$\mathrm{fac}(2)=\mathrm{fac}(1+1)=$$
\end{frame}

\begin{frame}{Recursion -- Ackermann function}
The Ackermann $\mathrm{Ack}$ function is defined by
$$\mathrm{Ack}(x,y) = \left\{ \begin{array}{ll}
y+1 & ; x=0 \\
\mathrm{Ack}(x-1,1) & ; y=0 \\
\mathrm{Ack}(x-1,\mathrm{Ack}(x,y-1)) & ; \mathrm{otherwise}.
\end{array} \right.$$
Calculate... 
$$\mathrm{Ack}(0,0) \stackrel{x=0,y=0}{=} 0+1 = 1,$$
$$\mathrm{Ack}(0,1) \stackrel{x=0,y=1}{=} 1+1 = 2,$$
$$\vdots$$
$$\mathrm{Arc}(0,y) \stackrel{x=0,y=y}{=} y+1,$$
$$\mathrm{Ack}(1,0) \stackrel{x=1,y=0}{=} \mathrm{Ack}(1-1,1) = \mathrm{Ack}(0,1)= 2$$
$$\begin{array}{ll}

\end{array}$$
\onslide<2->{This function gets very large very fast...
$$\mathrm{Ack}(4,3)=2^{2^{65536}}-3=2^{2^{2^{2^{2{^{2}}}}}}-3$$}
\end{frame}

\begin{frame}{Primitive recursive functions}
A \textit{primitive recursive function} is a special type of recursively defined function. Their technical definition is too complicated for here, but the factorial function defined earlier is primitive recursive while the Ackermann function is \textit{not}. \\
\vspace*{1cm}
\textbf{Theorem}: Any primitive recursive function can be defined in Peano arithmetic.
\end{frame}

\begin{frame}{G\"{o}del numbers}
The \underline{G\"{o}del number} of a formula in a language is a number assigned, uniquely, to each formula in that language. We do this by associating each symbol in a formula to a number. \\
\vspace*{1cm}
Our assignment for Peano arithmetic: \\
$0 \leftrightarrow 1$ \\
$\cdot \leftrightarrow 2$ \\
$+ \leftrightarrow 3$ \\
$= \leftrightarrow 4$ \\
$( \leftrightarrow 5$ \\
$) \leftrightarrow 6$ \\
$S0 \leftrightarrow 7$ \\
$SS0 \leftrightarrow 8$ \\
$SSS0 \leftrightarrow 9$ \\
$\vdots$
\end{frame}

\begin{frame}{G\"{o}del numbers}
Let's assign a G\"{o}del number to the following formula of Peano arithmetic: \\
$$S0 \cdot S0 = S0.$$
Since $S0 \leftrightarrow 7$, $\cdot \leftrightarrow 2$, $= \leftrightarrow 4$, we will encode the formula as an integer in the following way: consider the prime numbers $\{2,3,5,7,11,13,17,19,23,\ldots\}$; use the assigned value of each symbol as the exponent of each prime, in order, for each symbol
$${\color{red} S0} {\color{orange} \cdot} {\color{yellow} S0} {\color{green} =} {\color{blue} S0} \leftrightarrow 2^{\color{red} 7} 3^{\color{orange} 2} 5^{\color{yellow} 7} 7^{\color{green} 4} 11^{\color{blue} 7} = 4210982781390000000$$
Since we are using primes, this process can also be reversed: what formula is encoded by the number $152127360$?
$$152127360 \stackrel{\mathrm{factor}}{=}2^7 3^2 5^1 7^4 11^1 \leftrightarrow S0 \cdot 0 = 0$$
\end{frame}

\begin{frame}{Super G\"{o}del numbers}
The process described earlier can be applied to any sequence of integers. \\
\vspace*{1cm}
Once we have G\"{o}del numbers of formulas, we can talk about ``super" G\"{o}del numbers, which is the same process applied to proofs of formulas: a proof of a theorem is a list of formulas (in our deduction!). Each formula in the proof has its own G\"{o}del number. \\
\vspace*{1cm}
We say the ``super G\"{o}del" number of a proof defined by a sequence of formulas whose G\"{o}del numbers are $\{g_1,g_2,\ldots,g_n\}$ to be the number $2^{g_1}3^{g_2}5^{g_3}7^{g_4}11^{g_5}13^{g^6}\ldots$.
\end{frame}

\begin{frame}{``Super" G\"{o}del numbers}
From HW10:  \\
\begin{tabular}{|ll|}
\hline
Formula in proof & G\"{o}del number \\
\hline
(1) $S0 \cdot S0 = (S0 \cdot 0)+ S0$ & $g_1=2^7 3^2 5^7 7^4 11^5 13^7 17^2 19^1 23^6 29^3 31^7 $ \\
(2) $S0 \cdot 0=0$  & $g_2=2^7 3^2 5^1 7^4 11^ 13^1$ \\
(3) $S0 \cdot S0 = 0+S0$ & $g_3=2^7 3^2 5^7 7^4 11^1 13^7$  \\
(4) $S0+0=0+S0$ & $g_4 = 2^7 3^3 5^1 7^4 11^1 13^3 17^7$  \\
(5) $S0+0=S0$ & $g_5 = 2^7 3^3 5^1 7^4 11^7$   \\
(6) $S0=0+S0$ & $g_6 = 2^7 3^4 5^1 7^3 11^7$  \\
(7) $S0 \cdot S0 = S0$ & $g_7 = 2^7 3^2 5^7 7^4 11^7$  \\
\hline
\end{tabular}
The super G\"{o}del number of this proof of the formula $\phi = S0 \cdot S0=S0$ is
$$\ulcorner \phi \urcorner = 2^{g_1} 3^{g_2} 5^{g_3} 7^{g_4} 11^{g_5} 13^{g_6} 17^{g_7}$$

\end{frame}

\begin{frame}{Proof function}
The $\mathrm{Prf}$ function $\mathrm{Prf}(m,n)$ returns ``True" provided that $m$ is the super G\"{o}del number of a proof of the formula whose G\"{o}del number is $n$. It returns ``False" otherwise.  \\
\vspace*{1cm}
All that is required to check whether $\mathrm{Prf}(m,n)$ is true or false is to decode the number $m$ into a proof and decode $n$ into a formula. Observe whether or not the proof is a proof of $n$. \\
\vspace*{1cm}
\textbf{Theorem}: $\mathrm{Prf}$ is primitive recursive. 
\end{frame}

\begin{frame}{Diagonalization and $G$}
If $\phi$ is a formula, then the diagonalization of $\phi$ is the formula 
$$\mathrm{diag}(\phi)=(\exists y)(y=\ulcorner \phi \urcorner \wedge \phi).$$\\
\vspace*{1cm}
We define $\mathrm{Gdl}(m,n)=\mathrm{Prf}(m,\mathrm{diag}(n))$; this is true whenever $m$ is the super G\"{o}del number of a proof of the diagonalization of the formula whose G\"{o}del number is $n$. \\
\vspace{1cm}
\textbf{The self-reference}: define the formula $Uy=(\forall x)\neg \mathrm{Gdl}(x,y)$. The diagonalization of this formula is the formula we call $G$: 
$$G\stackrel{\mathrm{def}}{=} \mathrm{diag}(Uy)=(\exists y)(y=\ulcorner Uy \urcorner \wedge Uy).$$
\end{frame}

\begin{frame}{What does $G$ say?}
$$G\stackrel{\mathrm{def}}{=}(\exists y)(y=\ulcorner Uy \urcorner \wedge Uy)$$
\begin{enumerate}
\item $G=${\color{red} $(\exists y)$}({\color{blue} $y=\ulcorner Uy \urcorner$} $\wedge$ {\color{green} $Uy$}) 
\item $G=${\color{red} There is $y$} such that {\color{blue} $y=$ super G\"{o}del number of a proof of the formula ``$Uy$"} and {\color{green} $Uy$} 
\item $G=${\color{red} There is $y$} such that {\color{blue} $y=$ super G\"{o}del number of a proof of ``$(\forall x)\neg \mathrm{Gdl}(x,y)$"} and {\color{green} $(\forall x)\neg \mathrm{Gdl}(x,y)$} 
\item $G=${\color{red} There is $y$} such that {\color{blue} $y=$ super G\"{o}del number of a proof of ``$(\forall x)\neg \mathrm{Gdl}(x,y)$"} and {\color{green} no (natural) number $x$ exists such that $x$ is the super G\"{o}del number of a proof of $(\exists y)(y= \ulcorner Uy \urcorner \wedge Uy)$}
\end{enumerate}
Notice: the formula in line 1 appeared again inside of line 4... 
\end{frame}

\begin{frame}{Peano arithmetic does not prove $G$}
\textbf{Proof sketch:} Suppose a proof exists for the formula $G$. From this we see that $G$ is true, and moreover the proof has a super G\"{o}del number, say, $\ell$. \\
\vspace*{1cm}
But if $G$ is true, it means there is a number $y$, whose value is the G\"{o}del number of the formula $G$, and \textbf{no} number $x$ exists which is the super G\"{o}del number of a proof of $G$. \\
\vspace*{1cm}
So simultaneously the number $\ell$ would exist while we would also declare that no such number $x=\ell$ can exist. A contradiction! Therefore by RAA... Peano arithmetic does not prove $G$!
\end{frame}

\begin{frame}{Is $G$ true?}
Depends... from the perspective of ``true" meaning ``there exists a proof of it", then no, it is not. \\
\vspace*{1cm}
However, if you think about $G$ as encoding ``I am not provable", then because we have already argued that there is no proof for $G$, it is in fact \textit{true}... (``metamathematically"). \\
\vspace*{1cm}
From this we see that $G$ ``must be" true while also not having a proof (to have a proof would contradict itself). This is precisely why Peano arithmetic is \textbf{not} complete.
\end{frame}

\begin{frame}{The 2nd incompleteness theorem}
G\"{o}del's first incompleteness theorem shows that Peano arithmetic is not complete: $G$ is true but not provable. \\
\vspace*{1cm}
\textbf{Natural idea}: add $G$ to the list of axioms. Now we have a ``stronger theory" in which $G$ has a proof. Do this ``as much as necessary" to get a ``sufficiently powerful" theory that is complete. \\
\vspace*{1cm}
G\"{o}del's 2nd incompleteness theorem tells us that will \textit{always} fail: any theory that can ``express" Peano suffers from its own $G$-like sentence.
\end{frame}

\begin{frame}{Halting problem}
Can you write down a general method (``algorithm") that takes the source code of a computer program as an input and returns $1$ if the inputted program ``halts" (or ``terminates" or ``stops") or returns $0$ if the inputted program runs into an ``infinite loop"? \\
\vspace*{1cm}
\textit{Sometimes}... yes: \\
\texttt{while (2>1) \\
\{\\
\quad print 1\\
\}} \\
never terminates, while \\
\texttt{ print "Hello world!" }\\
terminates. \\
\end{frame}

\begin{frame}{Halting problem}
\textbf{Theorem}: No algorithm exists that can decide whether a given program will halt or not. \\
\textbf{Proof sketch:} Suppose such an algorithm exists, that is, suppose there is a program $\mathrm{Halt}$, which takes a program $t$ as input, and has output $\mathrm{Halt}(t)=1$ if the program $t$ terminates and $\mathrm{Halt}(t)=0$ if the program $t$ does \textbf{not} terminate. \\
\vspace*{1cm}
Define a program as follows: the program $y(t)$ takes an input program $t$ and asks ``does $t$ terminate or not?". If $\mathrm{Halt}(1)=1$, then $y$ decides to run an infinite loop. If $\mathrm{Halt}(t)=0$, then $y$ decides to terminate. \\
\vspace*{1cm}
What happens if we feed the program $y$ into itself? Does $y(y)$ terminate? If it does, then it doesn't. If it doesn't, then it does... therefore the $\mathrm{Halt}$ program does \textbf{not} exist!
\end{frame}
\end{document}
