Start on number 5

This commit is contained in:
2025-12-02 17:03:45 +01:00
parent b82602c614
commit 711426b8d0

71
5.org Normal file
View File

@ -0,0 +1,71 @@
#+title: Assignment 5
#+options: toc:nil
#+latex_header: \usepackage{parskip}
#+latex_header: \usepackage{stmaryrd}
In order to pass this assignment you have to get at least four points.
* (2p)
Let /NN/ be the set containing all closed expressions $e$ that implement functions from $\mathbb{N}$ to $\mathbb{N}$, i.e. expressions $e$ that, for some function $f \in \mathbb{N} \rightarrow \mathbb{N}$, satisfy $\forall n \in \mathbb{N}. \llbracket e\ \ulcorner n \urcorner \rrbracket = \ulcorner f\ n \urcorner$.
Either prove that the following function is $\chi$ computable, or that it is not $\chi$ computable:
\[ \text{has-fixpoint} \in \text{NN} \rightarrow \mathbb{B} \]
\[ \text{has-fixpoint}\ e = \text{if}\ \exists n \in \mathbb{N}. \llbracket e\ \ulcorner n \urcorner \rrbracket = \ulcorner n \urcorner\ \text{then}\ true\ \text{else}\ false \]
Note that Rices theorem, as stated in a lecture, applies to (total) functions from /CExp/ to /Bool/, whereas /has-fixpoint/ is a function from /NN/ to /Bool/.
** Answer
* (1p)
When is a function $f \in \mathbb{N} \rightarrow \mathbb{N}$ Turing-computable?
** Answer
Given that we have a way of representing elements of $\mathbb{N}$ as elements of $\text{List}\ \Sigma$, where $\Sigma$ is the input alphabet of the turing machine.
This can be used with the alphabet $\{0,1\}$, and represent a natural number $n$ as $1^n0$ (n ones followed by a single zero).
Then, a function $f \in \mathbb{N} \rightarrow \mathbb{N}$ would be turing computable if there is a turing machine $tm$ that satisfies the following conditions:
+ $\Sigma_{tm} = \Sigma$
+ $\forall n \in \mathbb{N}. \llbracket tm \rrbracket \ulcorner a \urcorner = \ulcorner f\ a \urcorner$
This means that the alphabet is the same, and that for any $n$, then the turing machine applied to the representation of $n$ should be the same as the represention of the function $f$ on $n$.
* (1p)
The following Turing machine implements a (total) function on the natural numbers. Which one? The natural number $n$ is represented by $1^n0$ (n ones followed by a single zero).
- Input alphabet: $\{0, 1\}$.
- Tape alphabet: $\{0, 1, \text{\textvisiblespace} \}$.
- States: $\{s_0, s_1, s_2\}$.
- Initial state: $s_0$.
- Transition function:
+ $\delta (s_0, 1) = (s_0, 1, R)$
+ $\delta (s_0, 0) = (s_1, 1, R)$
+ $\delta (s_1, \text{\textvisiblespace}) = (s_2, 0, R)$
** Answer
It describes the successor function on natural numbers.
* (2p)
Implement a Turing machine (with accepting states) that checks if two natural numbers are equal. The machine should use $\{0, 1\}$ as the input alphabet; you may use more symbols in the tape alphabet. The machine should accept input of the form $1^n01^n0$ (for any $n \in \mathbb{N}$). Input of the form $1^m01^n0$ where $m \ne n$ should be rejected.
Explain how your Turing machine works.
Make sure that you specify the Turing machine completely (the set of states, the alphabets, and so on). In addition to this specification you can also optionally submit your Turing machine in the format used by Anthony Morphett's [[http://morphett.info/turing/turing.html][Turing machine simulator]]. (If you go to “Advanced options”, then you can choose to use semi-infinite tapes.)
** Answer
* (2p)
Give a formal definition of (a reasonable variant of) two-tape Turing machines. Explain how such a Turing machine is defined. Also explain what its semantics is: what partial function from strings to strings does it compute?
** Answer
* (2p)
Consider the following variant of the basic Turing machines (without accepting states) presented in the lectures:
+ There are three possible directions: {L, R, S}. S means “stay” (do not move the head).
+ The meaning of S is specified formally by extending move with another clause:
\[ \text{move}\ S\ t\ = t \]
Give a translation /remove-stay/ that takes Turing machines of this kind to Turing machines of the basic kind. The translation should satisfy the following property for every Turing machine tm of the extended kind:
+ For every input $xs$ and output $ys$, the result of running $tm$ on $xs$ is $ys$ if and only if the result of running /remove-stay tm/ on $xs$ is $ys$.
You do not have to prove formally that this property holds.
/Hint/: You can handle the non-moving actions by first moving the head to the right, and then back to the left, using extra states to program this movement.
** Answer