Computability theory
Write $f: X \dashrightarrow Y$ for a partial function $f$ from $X$ to $Y$, i.e. a (total) function with domain $\op{dom}(f)\subseteq X$ and range $\mathrm{ran}(f)\subseteq Y$.
Write $f(x)\downarrow$ ("$f$ converges on input $x$") when $x\in \op{dom}(f)$ and $f(x)\uparrow$ ("$f$ diverges on input $x$") otherwise.
A register machine is a pair $M = (Q, P)$ where
-
$Q = \set{S_0, S_1, \ldots, S_n}$ is a finite set (of states) with two special elements $S_0 \neq S_1$ (the start state and the halt state); and
-
$P$ is a function with domain $Q$ (the program), such that each $P(S_i)$ is a $(Σ, Q)$-instruction, i.e. tuple of one of the following forms: ($j\in \Z_{\geq 1}$, $k, l\in \N$)
Instruction |
Interpretation |
|---|---|
$S_i: (j, +, k)$ |
Add 1 to the content of register $k$; |
$S_i: (j, -, k, l)$ |
If register $j$ is $0$: |
Let $M = (Q, P)$ be a register machine.
-
The upper register index $m=\op{upper}(P)$ of $M$ is the maximal register number that appears in any of the (finite) instructions in the range of $P$.
-
Given an input $(n_1, \ldots, n_k)\in \N^k$, initialise the content of the registers $R_1,\ldots, R_k$ to be $(n_1, \ldots, n_k)$. Start at state $S_1$ and keep following the instructions. Stop if we reach $S_0$.
-
Say $M$ halts on input $(n1, \ldots, nk)\in \N^k$ we reach $S_0$ (at some finite time). We write $P(n_1, \ldots, n_k)\downarrow$. If it does not halt, we write $P(n_1, \ldots, n_k)\uparrow$.
For a register machine $M$ and some $k\in \N$, define a partial function $f_{M,k}: \N^k \dashrightarrow \N$ by
-
$f_{M,k}(\v w)\uparrow$ if $M$ does not halt on input $\v w$; and
-
$f_{M,k}(\v w)=n$ if $M$ halts on input $\v w$ with register content $n$ in $R_0$ at the time of halting.
Write $\mathrm{W}_M = \op{dom}(f_{M,1})$. Two machines $M,M'$ are called weakly equivalent if $\mathrm{W}_M = \mathrm{W}_{M'}$.
A partial function $f: \N^k \dashrightarrow \N$ is called partial computable if there exists a register machine such that $f_{M,k} = f$.
The basic functions are
-
projection functions $π_{k,i}: \N^k \to \N: (n_1, \ldots, n_k)\mapsto n_i$;
-
the zero function $\N \to \N: n\mapsto 0$; and
-
the successor function $\N\to \N: n\mapsto n+1$.
Given $f: \mathbb{N}^k\dashrightarrow \N$ and $g_1, \ldots, g_k: \N^l \dashrightarrow \N$, the composition of $f$ with $(g_1, \ldots, g_k)$ is $$ \begin{align*} \N^l &\dashrightarrow \N \\ \v n &\mapsto f(g_1(\v n), \ldots, g_k(\v n)). \end{align*} $$
Given $f: \N^k \dashrightarrow \N$ and $g: \N^{k+2}\dashrightarrow \N$, the recursion result of $f$ and $g$ is $$ \begin{align*} h: \N^{k+1} &\dashrightarrow \N \\ (\v n, 0) &\mapsto f(\v n), \\ (\v n, \;n_{k+1}+ 1) &\mapsto g(\v n, \; n_{k+1}, \; h(\v n, n_{k+1})). \end{align*} $$
Given $f: \N^{k+1} \dashrightarrow \N$, the minimisation result of $f$ is $$ \begin{align*} \N^k &\dashrightarrow \N \\ \v n &\mapsto \begin{cases} m, &\text{minimal $m$ such that $f(\v n, m) = 0$}, \\ \uparrow, &\text{if $f(\v n, m) > 0$ for all $m$}. \end{cases} \end{align*} $$
The class of primitive recursive functions is the smallest class of partial functions containing all basic functions that is closed under composition and recursion.
The class of (partial) recursive functions is the smallest class of partial functions containing all basic functions that is closed under composition, recursion and minimisation.
Since addition, multiplication etc are recursive, they are computable. Thus we have access to arithmetics.
Then we encode $k$-tuples using (writing $p_i$ for the $i$-th prime) $$ \begin{align*} \N^k &\to \N \\ (n_1, \ldots, n_k) &\mapsto 2^{n_1} 3^{n_2} 5^{n_3} \ldots p_k^{n_k}. \end{align*} $$ Decode using $n \mapsto (n)_i$ the highest power of $p_i$ in $n$.
Alternatively, consider the Cantor zigzag bijection $$ \begin{align*} z: (i,j) \mapsto \frac{(i+j)(i+j+1)}{2} + i. \end{align*} $$ Its inverse is computable and lists $\N^2$ in shortlex ordering.
Every partial recursive function is partial computable, and vice versa.
The shortlex ordering on $\N^m$ is the total order defined by $(n_1, \ldots, n_m) < (n_1', \ldots, n_{m}')$ iff either
-
$\sum_{i=1}^{m} n_i < \sum_{i=1}^{m} n_i'$, or
-
$\sum_{i=1}^{m} n_i = \sum_{i=1}^{m} n_i'$ and there exists $j$ such that $n_1 = n_1', \ldots, n_{j-1} = n_{j-1}'$ and $n_j < n_j'$.
We devise a coding: (write $\op{code}(k)$ for the encoding of $k$)
-
Instruction: $\op{code}((j, +, k)) = 2^j 5^k$ and $\op{code}((j, -, k, l) ) = 2^j35^k7^l$.
-
Program: $\op{code}((i_1, \ldots, i_n)) = 2^n 3^{\op{code}(i_1)} 5^{\op{code}(i_2)} \ldots p_{n+1}^{i_n}$.
Write $f_{n,k}: \N^k \dashrightarrow \N$ for the partial function computed by machine encoded by $n$. If $n$ does not code a program, define $\op{dom}(f_{n,k}) = \emptyset$.
The software principle: there is a universal register machine $U$ such that $$ \begin{align*} f_{U,3}(n, k, m) = f_{n,k}((m)_1, \ldots, (m)_k). \end{align*} $$ (Proof)
We can then extend notation: for arbitrary $v\in \mathbb{W}$, define $f_{v,k}(\v w) = f_{U,2}(v,\op{code}(\v w))$.
Let $m,k\in \Z_{\geq 1}$, and write $\N^{m+k} = \N^{m} \times \N^{k}$.
A function $h: \N^{m+k}\dashrightarrow \N$ is partial computable iff there exists a total computable function $τ: \N^{m}\to \N$ such that $$ \begin{align*} h(\v a, \v x) = f_{τ(\v a), k}(\v x) \end{align*} $$ where $f_{n,k}$ is defined here.
Let $X\subseteq \N^k$.
The characteristic function of $X$ is $$ \begin{align*} χ_X(\v n) = \begin{cases} 1, &\v n\in X, \\ 0, &\v n\not\in X. \end{cases} \end{align*} $$ $X$ is called computable if $χ_X$ is computable.
The pseudo-characteristic function of $X$ is $$ \begin{align*} ψ_X(\v n) = \begin{cases} 1, &\v n\in X, \\ \uparrow, &\v n\not\in X. \end{cases} \end{align*} $$ $X$ is called computably enumerable if $ψ_X$ is computable.
If $X$ is computable, then so is $\N^k \setminus X$.
If $X$ is computable, then $X$ is computably enumerable. (Proof)
If $X\subseteq \N$, the following are equivalent:
The halting set and its two-variable variant are the sets $$ \begin{align*} \mathbf{K} &= \sb{w\in \N}{f_{w,1}(w)\downarrow}, \\ \mathbf{K}_0 &= \sb{(w,v)\in \N^2}{f_{w,1}(v)\downarrow}, \end{align*} $$ where $f_{w,1}$ is defined here.
The sets $\mathbf{K}$ and $\mathbf{K}_0$ are computably enumerable but not computable.
Let $g: \N\to \N$ be any total computable function.
There exists some $n_0\in \N$ such that $$ \begin{align*} f_{n_0, 1} = f_{g(n_0), 1}. \end{align*} $$ ($f_{n,k}$)
Let $A, B\subseteq \N$ be subsets.
A total computable function $f: \N\to \N$ is called a reduction of $A$ to $B$ if for all $w\in \N$, $$ \begin{align*} w\in A \iff f(w) \in B. \end{align*} $$
We say $A$ is many-one reducible to $B$ (denoted as $A\leq_m B$) if there is a reduction from $A$ to $B$.
We say $A$ is many-one equivalent to $B$ (denoted as $A\equiv_m B$) if $A\leq_m B$ and $B\leq_m A$.
$\leq_m$ is a partial order, i.e. it is reflexive ($A\leq_m A$ via $f=\id_\N$) and transitive (if $A_1 \leq_m A_2$ and $A_2 \leq_m A_3$, then $A_1 \leq_m A_3$ by concatenation of reductions).
$\equiv_m$ is an equivalence relation.
Note $A\leq_m B\iff \N\setminus A \leq_m \N\setminus B$. Thus $A$ and $\N\setminus A$ is either many-one equivalent or incomparable by $\leq_m$.
Let $L,L'\subseteq \mathbb{W}$. Suppose $L$${}\leq_m{}$$L'$.
-
If $L'$ is computable, then so is $L$.
-
If $L'$ is computably enumerable, then so is $L$.
Interpret $L\leq_m L'$ as "$L$ is at most as complicated as $L'$".
$\mathbf{K}$ and $\mathbb{W}\setminus \mathbf{K}$ are incomparable in $\leq_m$: otherwise $\mathbb{W}\setminus \mathbf{K}\equiv_m \mathbf{K}$ and in particular $\mathbb{W}\setminus \mathbf{K}\leq_m \mathbf{K}$, contradicting with $\mathbf{K}$ being $Σ_1$ but not $Π_1$.
Let $\mathcal{C}\subseteq \mathcal{P}(\N)$ be a collection of subsets and $A\subseteq \N$ be a subset.
Say $A$ is $\mathcal{C}$-hard if $X$${}\leq_m{}$$A$ for all $X\in \mathcal{C}$.
Say $A$ is $\mathcal{C}$-complete if $A$ is $\mathcal{C}$-hard and $A\in \mathcal{C}$.
A set $X\subseteq \N^k$ is called $Σ_n$ if there exists a computable set $Y\subseteq \N^{k+n}$ such that for all $\v x\in \N^k$, $$ \begin{align*} \v x\in X \iff \exists y_1 \forall y_2 \exists y_3 \forall y_4 \ldots m_n: (\v x, y_1, \ldots, y_m)\in Y. \end{align*} $$
$X$ is called $Π_n$ if $\mathbb{N}^k \setminus X$ is $Σ_n$, i.e. there exists a computable set $Y\subseteq \N^{k+n}$ such that $$ \begin{align*} \v x\in X \iff \forall y_1 \exists y_2 \forall y_3 \exists y_4 \ldots m_n: (\v x, y_1, \ldots, y_m)\in Y. \end{align*} $$
$X$ is called $Δ_1$ if $X$ is both $Σ_1$ and $Π_1$.
A set is computably enumerable iff it is $Σ_1$.
A set is computable iff it is $Δ_1$.
If $L\subseteq \mathbb{W}$ is a computable language, and $L\neq \emptyset$ and $L\neq \mathbb{W}$, then $L$ is $Δ_1$-complete.
The halting problem $\mathbf{K}$ is $Σ_1$-complete.
A set $I\subseteq \N$ is called an index set if it is closed under weak equivalence, i.e. if $w\in I, v\in \N$ and $\mathrm{W}_w = \mathrm{W}_v$, then $v\in I$.
-
Any non-empty index set is infinite by the padding lemma: adding arbitrarily many unreachable instructions results in a distinct program but same partial function.
If an index set $I$ is not trivial ($I\neq \emptyset$ and $I\neq \N$), then $I$ is not computable.
In particular, let $e\in \N$ such that $\mathrm{W}_e = \emptyset$.
-
If $e\in I$, then $\N\setminus{}$$\mathbf{K}$${}\leq_m I$;
-
If $e\not\in I$, then $\mathbf{K}\leq_m I$.
Consider an encoding of grammars: for every $n\in \N$, there is a grammar $G_n$, and all grammars are of this form.
Then we can recast the decision problems:
-
the word problem: $\sb{(u,v)}{u\in \mathcal{L}(G_v)}$;
-
the emptiness problem: $\sb{u}{\mathcal{L}(G_u) = \emptyset}$;
-
the equivalence problem: $\sb{(u,v)}{\mathcal{L}(G_u) = \mathcal{L}(G_v)}$,
and we say a decision problem is solvable if the set is computable.
It can be shown that there are total computable functions that translate between codes of grammars and register machines and vice versa. They then witness the many-one equivalences $$ \begin{alignat}{1} \mathbf{K}_0 &= \sb{(w,v)}{w\in \mathrm{W}_v} &&\equiv_m \sb{(u,v)}{u\in \mathcal{L}(G_v)}, \\ \mathbf{Emp} &:= \sb{u}{\mathrm{W}_u = \emptyset} &&\equiv_m \sb{u}{\mathcal{L}(G_u) = \emptyset}, \\ \mathbf{Fin} &:= \sb{u}{\mathrm{W}_u \text{ is finite}} &&\equiv_m \sb{u}{\mathcal{L}(G_u) \text{ is finite}}, \\ \mathbf{Inf} &:= \sb{u}{\mathrm{W}_u \text{ is infinite}} &&\equiv_m \sb{u}{\mathcal{L}(G_u) \text{ is infinite}}, \\ \mathbf{Cof} &:= \sb{u}{\N \setminus \mathrm{W}_u \text{ is finite}} &&\equiv_m \sb{u}{Σ^\ast \setminus \mathcal{L}(G_u) \text{ is finite}}, \\ \mathbf{Tot} &:= \sb{u}{\mathrm{W}_u = \N} &&\equiv_m \sb{u}{\mathcal{L}(G_u) = Σ^\ast}, \\ \end{alignat} $$
$\mathbf{Emp}, \mathbf{Fin}, \mathbf{Inf}, \mathbf{Tot}$ are non-trivial index sets. By Rice's theorem, we obtain $\mathbb{N}\setminus \mathbf{K} \leq_m \mathbf{Emp}, \mathbf{Fin}$ and $\mathbf{K}\leq_m \mathbf{Inf}, \mathbf{Tot}$. This shows the emptiness problem for type 0 languages is not solvable.
$\mathbf{Fin}$ is neither $Σ_1$ nor $Π_1$.
Consequently $\mathbf{Inf}$ $= \N\setminus \mathbf{Fin}$ is neither $Σ_1$ nor $Π_1$.
By describing using the total computable set $T = \sb{(m,x,n)}{\text{program }m\text{ with input }x\text{ terminates in }n\text{ steps}}$, we see
-
$\mathbf{Emp} = \sb{m}{\forall x \forall n: (m,x,n)\not\in T}$ is $Π_1$;
-
$\mathbf{Fin} = \sb{m}{\exists X\forall x\forall n: x\leq X \text{ or } (m,x,n)\not\in T}$ is $Σ_2$ so $\mathbf{Inf}$ is $Π_2$;
-
$\mathbf{Cof} = \sb{m}{\exists X\forall x\exists n: x\leq X \text{ or } (m,x,n)\in T}$ is $Σ_3$;
-
$\mathbf{Tot} = \sb{m}{\forall x\exists n: (m,x,n)\in T}$ is $Π_2$.