You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here we have ended up with the halting problem being uncomputable.
63
63
64
+
\begin{sidenotebox}{Collatz Conjecture}
65
+
A famous example of a simple algorithm not yet determined to terminate on all inputs.
66
+
\begin{quote}
67
+
\textit{Given some input $n$, how many steps of applying $f$ are required to reach $1$, given:}
68
+
\end{quote}
69
+
\[f = \begin{cases}
70
+
\cfrac{n}{2} & n \text{ is even} \\
71
+
3n + 1 & n \text{ is odd} \\
72
+
\end{cases}\]
73
+
The conjecture states that the sequence from any positive integer $n$ will eventually go to zero. And hence any algorithm generating the sequence will terminate. This remains unproven.
74
+
\begin{minted}{haskell}
75
+
-- get the sequence for positive integer
76
+
-- note we have use Integral (as proven to terminate for all values of fixed size Int)
77
+
collatz :: (Integral a) => a -> [a]
78
+
collatz 1 = [1]
79
+
collatz n
80
+
| odd n = n : collatz (n * 3 + 1)
81
+
| otherwise = n : collatz (n `div` 2)
82
+
83
+
limit :: (Integral a) => a -> Int
84
+
limit = length . collatz
85
+
\end{minted}
86
+
\end{sidenotebox}
87
+
64
88
\subsection{Undecidable Set of Numbers}
65
89
Given a set $S \subseteq\mathbb{N}$, its characteristic function is:
If such a register machine exists to compute $\chi_{S_1}$, we can create another register machine, simply checking $0$. Hence as from the previous example, there is no register machine to determine $S_0$, there is none to determine $S_1$.
113
+
114
+
115
+
\begin{exambox}{2biii}{2020/21}
116
+
\textit{\dots continued from Q2bii - 2020/21}
117
+
\\
118
+
\\ Take the machine $M$ in (ii) and use the substitutions to create register machine $K$:
119
+
\begin{center}
120
+
\begin{tabular}{l p{.8\textwidth}}
121
+
$E \triangleq even \ R_0$ & exiting by $\twoheadrightarrow$ if odd, or by $\to$ if even. \\
122
+
$H \triangleq R_0 := \sfrac{R_0}{2}$ & exiting by $\twoheadrightarrow$ if odd, or by $\to$ if even. \\
123
+
$T \triangleq R_0 := 3\times R_0 + 1$ & with no $\twoheadrightarrow$ needed. \\
124
+
\end{tabular}
125
+
\end{center}
126
+
Describe what the Register Machine $K$ computing? In particular sketch an execution of $K$ with initially $R_0 = 0, 1, 2, 3, 4$ and $5$.
127
+
\end{exambox}
128
+
\begin{exambox}{2biv}{2020/21}
129
+
\textit{\dots continued from Q2biii - 2020/21}
130
+
\\
131
+
\\ To the best of our knowledge nobody could yet show that $K$ halts for all
132
+
possible initial values of $R_0$. How does this relate to the Halting problem
\\ Using Church numerals, give an equivalent $\lambda$-term (program) C, i.e. for all $n > 0$ we have $C \ \underline{n} \to_\beta^* \underline{m} $ if and only if the execution of register machine $K$ also halts with $R_0 = m$ when started with $R_0 = n$.
233
+
\\
234
+
\\ You can use the pre-defined operations from the lecture ($plus$, $mult$, $succ$,
235
+
$pred$, $ifz$, etc.) and also integer division ($div$) and reminder ($rem$). It helps to
236
+
use various subroutines.
237
+
\end{exambox}
238
+
239
+
\begin{exambox}{2d}{2021/22}
240
+
Consider the following recursively defined sequence of integers $x_i$:
241
+
\[\begin{split}
242
+
x_0 & = x _ 1 = 1 \\
243
+
x_i & = x_{i-2}^2 + 2 x_{i-1} \\
244
+
\end{split}\]
245
+
Implement this in the $\lambda$-calculus using Church numerals, i.e. write a lambda term $f$ such that $f \ \underline{n}$ reduces to $\underline{x_n}$.
246
+
\\
247
+
\\ You can use functions defined in the lecture, e.g $plus$, $mult$, $ifz$ etc. It might help to define subroutines.
248
+
\\
249
+
\\ Sketch the execution of $f \ \underline{2}$ (you can use $\to_\beta^*$ rather than $\to_\beta$).
0 commit comments