Lecture 10¶
Numerical Functions¶
Definition
A Turing machine \(M\) computes \(f: \mathbb{N}^K \rightarrow \mathbb{N}\) if \(\forall n_1, \dots, n_k \in \mathbb{N}\),
where \(\text{bin}(x)\) is the binary encoding of \(x\).
And we say \(f\) is computable.
Primitive Recursive Function¶
Basic Functions¶
-
zero function
\[ \text{zero}(n_1, \dots, n_k) = 0. \] -
identity function
\[ \text{id}_{k, j}(n_1, \dots, n_k) = n_j. \] -
successor function
\[ \text{succ}(n) = n + 1. \]
Theorem
Basic functions are computable.
Composition¶
If we have a computable function \(g: \mathbb{N}^k \rightarrow \mathbb{N}\) and several computable functions \(h_1, \dots, h_k: \mathbb{N}^l \rightarrow \mathbb{N}\). The way to contruct the following function \(f: \mathbb{N}^l \rightarrow \mathbb{N}\) is called composition.
Recursive Definition¶
If we have two computable functions \(g: \mathbb{N}^k \rightarrow \mathbb{N}\) and \(h: \mathbb{N}^{k + 2} \rightarrow \mathbb{N}\). The way to contruct the following function \(f: \mathbb{N}^{k + 1} \rightarrow \mathbb{N}\) is called recursive definition.
- \(f(n_1, \dots, n_k, 0) = g(n_1, \dots, n_k)\).
- \(\forall t \in \mathbb{N}\), \(f(n_1, \dots, n_k, t + 1) = h(n_1, \dots, n_k, t, f(n_1, \dots, n_k, t))\).
Example
A typical recursive function is factorial: \(f(0) = 1\) and \(f(n + 1) = (n + 1)f(n)\). In this case, we have
- \(k = 0\).
- \(g(n) = 1\).
- \(h(n, f(n)) = (n + 1)f(n)\).
Definition
Primitive recursive functions are the basic functions and those obtained from the basic functions by applying composition and recursive definition a finite number of times.
Theorem
Primitive recursive functions are computable.
Definition
If the output of the primitive recursive function is either 0 or 1, then it's called a predicate.
Theorem
If \(g\), \(h\) are primitive recursive and \(p\) is a predicate, then
is also primitive recursive.
Here we give some examples of primitive recursive functions.
Example
-
\(\text{plus2}(n) = n + 2\)
\[ \text{succ}(\text{succ}(n)) \] -
\(\text{plus}(m, n) = m + n\)
\[ \left\{ \begin{aligned} \text{plus}(m, 0) &= m = \text{id}_{1, 1}(m), \\ \text{plus}(m, n + 1) &= \text{plus}(m, n) + 1 = \text{succ}(\text{plus(m, n)}). \end{aligned} \right. \]But it's not strict enough actually. The following is the a stricter version. Since it's trivial, we needn't actually expand it commonly.
\[ \left\{ \begin{aligned} \text{plus}(m, 0) &= m = \text{id}_{1, 1}(m), \\ \text{plus}(m, n + 1) &= \text{succ}(\text{plus(m, n)}) = h(m, n, \text{plus}(m, n)). \end{aligned} \right. \]where
\[ h(m, n, \text{plus}(m, n)) = \text{succ}(\text{id}_{3,3}(m, n, \text{plus}(m, n))). \] -
\(\text{mult}(m, n) = m \cdot n\)
\[ \left\{ \begin{aligned} \text{mult}(m, 0) &= 0 = \text{zero}(m), \\ \text{mult}(m, n + 1) &= \text{mult}(m, n) + m = \text{plus}(\text{mult(m, n)}, m). \end{aligned} \right. \] -
\(\text{exp}(m, n) = m^n\)
\[ \left\{ \begin{aligned} \text{exp}(m, 0) &= 1 = \text{succ}(\text{zero}(m)), \\ \text{exp}(m, n + 1) &= \text{exp}(m, n) \cdot m = \text{mult}(\text{exp(m, n)}, m). \end{aligned} \right. \] -
constant function: \(f(n_1, \dots, n_k) = c\)
\[ \underbrace{\text{succ}(\dots(\text{succ}}_{c \text{ times}}(\text{zero}(n_1, \dots, n_k)) \dots ) \] -
positive / sign function: \(\text{positive}(n) = \text{sgn}(n) = \left\{\begin{aligned} 1, n > 0, \\ 0, n = 0. \end{aligned}\right.\)
\[ \left\{ \begin{aligned} \text{sgn}(0) &= 0, \\ \text{sgn}(n + 1) &= 1. \end{aligned} \right. \] -
predecessor function: \(\text{pred}(n) = \left\{\begin{aligned} &n - 1, &n > 0, \\ &0, &n = 0. \end{aligned}\right.\)
\[ \left\{ \begin{aligned} \text{pred}(0) &= 0, \\ \text{pred}(n + 1) &= n = \text{id}_{2, 1}(n, \text{pred}(n)) = n. \end{aligned} \right. \] -
non-negative substraction \(m \sim n = \max(m - n, 0)\)
\[ \left\{ \begin{aligned} m \sim 0 &= m, \\ m \sim (n + 1) &= (m \sim n) \sim 1 = \text{pred}(m \sim n). \end{aligned} \right. \] -
\(\text{iszero}(n) = \left\{\begin{aligned} &1, &n = 0, \\ &0, &n > 0. \end{aligned}\right.\)
\[ 1 \sim \text{positive}(n) \] -
\(\text{geq}(m, n) = \left\{\begin{aligned} &1, &m \ge n, \\ &0, &m < n. \end{aligned}\right.\)
\[ \text{iszero}(n \sim m) \] -
\(\text{eq}(m, n) = \left\{\begin{aligned} &1, &m = n, \\ &0, &m \neq n. \end{aligned}\right.\)
\[ \text{geq}(m, n) \cdot \text{geq}(n, m) \] -
\(\text{rem}(m, n) = m\ \%\ n\).
\[ \left\{ \begin{aligned} \text{rem}(0, n) &= 0, \\ \text{rem}(m + 1, n) &= \left\{\begin{aligned} & 0, && \text{if $m + 1$ is divisible by $n$}, \\ & \text{rem}(m, n), && \text{otherwise}. \end{aligned}\right. \end{aligned} \right. \]where \(m + 1 \text{ is divisible by } n \Leftrightarrow \text{eq}(\text{rem}(m, n), \text{pred}(n))\).
-
\(\text{div}(m, n) = \lfloor m / n \rfloor\). (\(n \neq 0\))
\[ \left\{ \begin{aligned} \text{div}(0, n) &= 0, \\ \text{div}(m + 1, n) &= \left\{\begin{aligned} & \text{div}(m, n) + 1, && \text{if $m + 1$ is divisible by $n$}, \\ & \text{div}(m, n), && \text{otherwise}. \end{aligned}\right. \end{aligned} \right. \] -
\(\text{digit}(m, n, p) = a_{m - 1}\).
\[ \text{div}(\text{rem}(n, p^m), p^{m - 1}) \] -
\(\text{sum}_f(m, n) = \sum\limits_{k = 0}^{n} f(m, k)\), where \(f\) is primitive recursive.
\[ \left\{ \begin{aligned} \text{sum}_f(m, 0) &= f(m, 0), \\ \text{sum}_f(m, n + 1) &= \text{sum}_f(m, n) + f(m, \text{succ}(n)). \end{aligned} \right. \]Wrong Consideration
\[ \text{sum}_f(m, n) = \underbrace{f(m, 0) + f(m, 1) + \dots + f(m, n)}_{n \text{ times}} \]Notice that the theorem that sum of two primitive recursive functions is primitive recursive can not induce that sum of \(n\) primitive recursive function is primitive recursive, when \(n\) is a variable and is an input of the function.
-
\(\text{mult}_f(m, n) = \prod\limits_{k = 0}^{n} f(m, k)\), where \(f\) is primitive recursive.
\[ \left\{ \begin{aligned} \text{mult}_f(m, 0) &= f(m, 0), \\ \text{mult}_f(m, n + 1) &= \text{mult}_f(m, n) \cdot f(m, \text{succ}(n)). \end{aligned} \right. \] -
\(g_p(n) = \left\{\begin{aligned} &1, && \text{if } \exists n' \le n, p(n') = 1 , \\ &0, &&\text{otherwise}. \end{aligned}\right.\), where \(p\) is a predicate.
\[ g_p(n) = p(0) \vee p(1) \vee \dots \vee p(n) = \text{positive} \left(\sum_{n'=0}^n p(n')\right) = \text{positive}(\text{sum}_p(n)) \]
Note
If \(p\) and \(q\) are predicates, then
Computability¶
Suppose we define
Lemma
\(\text{PR}\) is decidable.
Lemma
\(\text{C}\) is undecidable.
Proof
Assume that \(C\) is decidable. Then \(C' = \{\langle f\rangle | f \text{ is a unary computable numerical function}\} \subseteq C\) is also decidable.
Then \(C'\) is lexicographically Turing enumerable. Thus we can enumerate \(C'\) by
Now we construct a TM \(M\) = on input \(n\),
- enumerate \(C'\) to get \(g_n\).
- compute \(g_n(n)\).
- output \(g_n(n) + 1\).
Then \(g^*(n) = g_n(n) + 1\) is unary computable numerical function and thus \(g^* \in C'\).
However, \(\forall n \in \mathbb{N}\), \(g^* \neq g_n\), which leads to a contradiction.
So we can conclude that
That's not good since all computable function can't build up by that simple functions!
But now we consider add an additional operation of the primitive recursive function: minimalization.
Minimalization¶
Definition
Suppose \(g: \mathbb{N}^{k + 1} \rightarrow \mathbb{N}\), and we define
Then we call \(f\) is a minimalization of \(g\), denoted by
Definition
A function \(g\) is minimalizable if \(g\) is computable and \(\forall n_1, \dots, n_k\), \(\exists m \ge 0\), such that \(g(n_1, \dots, n_k, m) = 1\).
Example
This function is minimalizable.
Theorem
If \(g: \mathbb{N}^{k + 1} \rightarrow \mathbb{N}\) is minimalizable, then \(\mu_m[g(n_1, \dots, n_k, m) = 1]\) is computable.
Theorem
The problem that
Given a function \(g\), is \(g\) minimalizable?
is undecidable.
创建日期: 2023.12.12 22:53:54 CST