Chapter 23

Partial Recursive Functions

[26/100%]
Show
LaTeX
Problem 558

Let three functions be given: f(x,y,z)=xy+z,g(x,y)=2x+yf(x, y, z)=x y+z, g(x, y)=2 x+y, h(x)=2x2h(x)=2 x^{2}. Determine the function F(2)F^{(2)} defined as follows: f(h(id⁡12),g(h(id⁡22),id⁡22),id⁡22)f\left(h\left(\operatorname {id}_{1}^{2}\right), g\left(h\left(\operatorname {id}_{2}^{2}\right), \operatorname {id}_{2}^{2}\right), \operatorname {id}_{2}^{2}\right)? ⊛\circledast

?
Problem 559

Determine the value of the following p.r.f.'s (partial recursive functions):

?
(a)

f=Pr⁡[0,s(id⁡12+id⁡12)+id⁡22]f=\operatorname {Pr}\left[0, s\left(\operatorname {id}_{1}^{2}+\operatorname {id}_{1}^{2}\right)+\operatorname {id}_{2}^{2}\right];

(b)

f=Pr⁡[0,s(id⁡12)+s(id⁡12)+id⁡22]f=\operatorname {Pr}\left[0, s\left(\operatorname {id}_{1}^{2}\right)+s\left(\operatorname {id}_{1}^{2}\right)+\operatorname {id}_{2}^{2}\right];

(c)

f=Pr⁡[0,s(3⋅id⁡12⋅s(id⁡12))+id⁡22]f=\operatorname {Pr}\left[0, s\left(3 \cdot \operatorname {id}_{1}^{2} \cdot s\left(\operatorname {id}_{1}^{2}\right)\right)+\operatorname {id}_{2}^{2}\right]. ⊛\circledast

Problem 560

The g.r.f. (general recursive function) f(x)f(x) is given as follows:

Pr⁡[0,s(id⁡12)+s(id⁡12)+id⁡12+id⁡12+id⁡22+id⁡22]. \operatorname {Pr}\left[0, s\left(\operatorname {id}_{1}^{2}\right)+s\left(\operatorname {id}_{1}^{2}\right)+\operatorname {id}_{1}^{2}+\operatorname {id}_{1}^{2}+\operatorname {id}_{2}^{2}+\operatorname {id}_{2}^{2}\right].

Prove that f(x)=3⋅2x+1−4x−6f(x)=3 \cdot 2^{x+1}-4 x-6. ⊛\circledast

?
Problem 561

Find the value F(5)F(5) for the following functions:

?
(a)

F=Pr⁡[1,h]F=\operatorname {Pr}[1, h], where h(y,z)=⌊2z/z2⌋h(y, z)=\left\lfloor 2^{z} / z^{2}\right\rfloor;

(b)

F=Pr⁡[1,h]F=\operatorname {Pr}[1, h], where h(y,z)=⌊2z/z⌋h(y, z)=\left\lfloor 2^{z} / z\right\rfloor;

(c)

F=Pr⁡[2,h]F=\operatorname {Pr}[2, h], where h(y,z)=3z÷(2y+1)h(y, z)=3 z \div (2 y+1). ⊛\circledast

Problem 562

Show that the following functions are g.r.f.'s:

?
(a)

pow⁡(x,y)=xy\operatorname {pow}(x, y)=x^{y} — exponentiation;

(b)

fact⁡(x)=x!\operatorname {fact}(x)=x! — factorial;

(c)

if⁡(x,y,z)\operatorname {if}(x, y, z) — the conditional operation,

if⁡(x,y,z)={y, if x≠0z, otherwise  \operatorname {if}(x, y, z)= \begin{cases} y, & \text{ if } x \neq 0 \\ z, & \text{ otherwise }\end{cases}
(d)

min⁡(n)(x1,…,xn)\min^{(n)}\left(x_{1}, \ldots , x_{n}\right) — the smallest of the arguments, n>0n>0;

(e)

max⁡(n)(x1,…,xn)\max^{(n)}\left(x_{1}, \ldots , x_{n}\right) — the largest of the arguments, n>0n>0;

(f)

diff⁡=∣x−y∣\operatorname {diff}=\left|x-y\right| — the absolute difference;

(g)

 mod (x,y)\bmod (x, y) — the remainder of dividing xx by yy;

(h)

div⁡(x,y)=⌊x/y⌋\operatorname {div}(x, y)=\lfloor x / y\rfloor — integer quotient. ⊛\circledast

Problem 563

Prove that if the function f(x1,…,xn)f\left(x_{1}, \ldots , x_{n}\right) is a p.r.f., then the function g(x1,…,xn)=f(xi1,…,xin)g\left(x_{1}, \ldots , x_{n}\right)=f\left(x_{i_{1}}, \ldots , x_{i_{n}}\right) is also a p.r.f. for every permutation (i1,…,in)(i_{1}, \ldots , i_{n}) of the numbers 1,2,…,n1,2, \ldots , n. ⊛\circledast

?
Problem 564

We say that the function h(n+1)h^{(n+1)} is obtained by bounded minimization of the function f(n+1)f^{(n+1)} (denoted h=μlim⁡fh=\mu_{\lim } f), if h(xˉ,y)=yh(\bar{x}, y)=y, when f(xˉ,y)≠0f(\bar{x}, y) \neq 0 for all z<yz<y, and otherwise h(xˉ,y)h(\bar{x}, y) equals the smallest z<yz<y for which f(xˉ,z)=0f(\bar{x}, z)=0. Prove that the function μlim⁡f\mu_{\lim } f can be constructed from ff and the basis functions by means of superposition and primitive recursion. ⊛\circledast

?
Problem 565

Let g(x1,…,xn−1,xn)g\left(x_{1}, \ldots , x_{n-1}, x_{n}\right) be a p.r.f., and let aa and b>0b>0 be natural numbers. Prove that the function

f(x1,…,xn−1,xn)={a, if xn<bg(x1,…,xn−1,xn−b), if xn⩾b f\left(x_{1}, \ldots , x_{n-1}, x_{n}\right)= \begin{cases} a, & \text{ if } x_{n}<b \\ g\left(x_{1}, \ldots , x_{n-1}, x_{n}-b\right), & \text{ if } x_{n} \geqslant b\end{cases}

is also a p.r.f. ⊛\circledast

?
Problem 566

Find the value F(9)F(9) and F(17)F(17) for F=μfF=\mu f and the following functions f(2)f^{(2)}. Determine for which of them F(x)=⌊x⌋F(x)=\lfloor \sqrt{x}\rfloor holds:

?
(a)

f(x,y)=y2÷xf(x, y)=y^{2} \div x;

(b)

f(x,y)=x÷y2f(x, y)=x \div y^{2};

(c)

f(x,y)=(x+1)÷y2f(x, y)=(x+1) \div y^{2};

(d)

f(x,y)=(x+1)÷(y+1)2f(x, y)=(x+1) \div (y+1)^{2};

(e)

f(x,y)=x÷(y+1)2f(x, y)=x \div (y+1)^{2}. ⊛\circledast

Problem 567

Determine for which of the following functions f(3)f^{(3)} we have F(x)=⌊y/x⌋F(x)=\lfloor y / x\rfloor, where F=μfF=\mu f and x≠0x \neq 0:

?
(a)

f(x,y,i)=y÷ixf(x, y, i)=y \div i x;

(b)

f(x,y,i)=y÷(i+1)xf(x, y, i)=y \div (i+1) x;

(c)

f(x,y,i)=(y+1)÷ixf(x, y, i)=(y+1) \div i x;

(d)

f(x,y,i)=(y+1)÷i(x+1)f(x, y, i)=(y+1) \div i(x+1);

(e)

f(x,y,i)=(y+1)÷(i+1)xf(x, y, i)=(y+1) \div (i+1) x. ⊛\circledast

Problem 568

Which of the following expressions define the number τ(x)\tau (x) of distinct divisors of xx?

?
(a)

x−∑i<xtest⁡( mod (x,s(i)))x-\sum_{i<x} \operatorname {test}(\bmod (x, s(i)));

(b)

x−∑i<xnot⁡( mod (x,s(i)))x-\sum_{i<x} \operatorname {not}(\bmod (x, s(i)));

(c)

∑i<xtest⁡( mod (x,s(i)))\sum_{i<x} \operatorname {test}(\bmod (x, s(i)));

(d)

∑i<xnot⁡( mod (x,s(i)))\sum_{i<x} \operatorname {not}(\bmod (x, s(i))). ⊛\circledast

Problem 569

Show that the following functions are p.r.f.'s:

?
(a)

rt⁡(n,x)=⌊xn⌋\operatorname {rt}(n, x)=\lfloor \sqrt[n]{x}\rfloor — the integer part of the nn-th root of xx;

(b)

log⁡(i,x)=⌊log⁡ix⌋\log (i, x)=\left\lfloor \log_{i} x\right\rfloor;

(c)

p(x)=1p(x)=1, if xx is a prime number, and p(x)=0p(x)=0 otherwise;

(d)

pn⁡(k)\operatorname {pn}(k) — the kk-th prime number in increasing order, pn⁡(0)=2\operatorname {pn}(0)=2;

(e)

σ(x)\sigma (x) — the sum of the divisors of xx, taking σ(0)=0\sigma (0)=0;

(f)

digit⁡(n,m,i)\operatorname {digit}(n, m, i) — the ii-th digit in the base-mm representation of nn: that is, if n=∑i=0∞aimin=\sum_{i=0}^{\infty } a_{i} m^{i}, where 0⩽ai<m0 \leqslant a_{i}<m, then digit⁡(n,m,i)=ai\operatorname {digit}(n, m, i)=a_{i};

(g)

gcd⁡(x,y)\gcd (x, y) — the greatest common divisor of xx and yy. ⊛\circledast

Problem 570

Determine the p.r.f. l(1)l^{(1)} whose value equals log⁡2x\log_{2} x when xx is a power of two, and is undefined otherwise. ⊛\circledast

?
Problem 571

On the Euclidean coordinate plane, a disk CC is given, centered at the point (100,100)(100,100) with radius 50. Prove that the following function r(2)r^{(2)} is partially recursive: r(x,y)r(x, y) is defined if and only if the point (x,y)(x, y) lies outside the disk CC, and its value equals the integer part of the distance from (x,y)(x, y) to the disk (that is, to the point of the disk CC closest to (x,y)(x, y)). ⊛\circledast

?
Problem 572

A g.r.f. that can be constructed without using minimization is called primitively recursive. Let the functions gg and ff be primitively recursive, h=μgh=\mu g, hh a g.r.f., and let hh be majorized by the function f:h(xˉ)<f(xˉ)f: h(\bar{x})<f(\bar{x}) for all xˉ\bar{x}. Prove that hh is also primitively recursive. ⊛\circledast

?
Problem 573

Prove that if the values of a g.r.f. f(x)f(x) are changed on a finite set, then the resulting function f′(x)f^{\prime }(x) is also a g.r.f. ⊛\circledast

?
Problem 574

Prove that from the constant 0 and the functions id⁡mn\operatorname {id}_{m}^{n}, by means of superposition and primitive recursion, one cannot obtain the function s(x)=x+1s(x)=x+1 or the function d(x)=2xd(x)=2 x. Hint. By induction on the construction of the function, prove that for all functions constructed in this way, the inequality f(x1,…,xn)<2f\left(x_{1}, \ldots , x_{n}\right)<2 holds for arbitrary x1,…,xn<2x_{1}, \ldots , x_{n}<2. ⊛\circledast

?
Problem 575

Let ff be a g.r.f. that is one-to-one on ω\omega. Prove that the inverse function f−1f^{-1} is also a g.r.f., by explicitly constructing it. ⊛\circledast

?
Problem 576

Let g(x1,…,xn,y)g\left(x_{1}, \ldots , x_{n}, y\right) be a g.r.f. Prove that the function

f(x1,…,xn,y,z)={∑i=0zg(x1,…,xn,y+i), for y⩽z,0, for y>z f\left(x_{1}, \ldots , x_{n}, y, z\right)= \begin{cases} \sum _{i=0}^{z} g\left(x_{1}, \ldots , x_{n}, y+i\right), & \text{ for } y \leqslant z, \\ 0, & \text{ for } y>z\end{cases}

is general recursive. ⊛\circledast

?
Problem 577

Prove that if the functions f(x1,…,xn,y),g(x1,…,xn,y)f\left(x_{1}, \ldots , x_{n}, y\right), g\left(x_{1}, \ldots , x_{n}, y\right), and h(x1,…,xn,y)h\left(x_{1}, \ldots , x_{n}, y\right) are general recursive, then the function

\begin{aligned} & F\left(x_{1}, \ldots , x_{n}\right)=\min \left\{ y: f\left(x_{1}, \ldots , x_{n}, y\right)=0 \text{ or } \\ & \quad g\left(x_{1}, \ldots , x_{n}, y\right)>h\left(x_{1}, \ldots , x_{n}, y\right)\right\} \end{aligned}

is a p.r.f. ⊛\circledast

?
Problem 578

Suppose that all pairs (x,y)(x, y) of natural numbers are ordered by increasing sum x+yx+y, and pairs with the same sum — by increasing coordinate xx. This order looks like this:

(0,0),(0,1),(1,0),(0,2),(1,1),(2,0),……,(0,x+y),(1,x+y−1),…,(x,y),…,(x+y,0),… \begin{aligned} & (0,0),(0,1),(1,0),(0,2),(1,1),(2,0), \ldots \\ & \quad \ldots ,(0, x+y),(1, x+y-1), \ldots ,(x, y), \ldots ,(x+y, 0), \ldots \end{aligned}

Let ⟨x,y⟩\langle x, y\rangle be the number of the pair (x,y)(x, y) in this order (we take the pair (0,0) to have number 0). Then the function ⟨,⟩\langle ,\rangle numbers all pairs of natural numbers in a one-to-one fashion.

?
(a)

Prove that ⟨x,y⟩=(x+y)(x+y+1)2+x\langle x, y\rangle =\frac{(x+y)(x+y+1)}{2}+x.

(b)

Find the inverse functions ⟨⟩1\langle \rangle_{1} and ⟨⟩2\langle \rangle_{2} such that the equalities ⟨⟨x,y⟩⟩1=x,⟨⟨x,y⟩⟩2=y\langle \langle x, y\rangle \rangle_{1}=x,\langle \langle x, y\rangle \rangle_{2}=y hold, and consequently ⟨⟨z⟩1,⟨z⟩2⟩=z\langle \langle z\rangle_{1},\langle z\rangle_{2}\rangle =z.

(c)

Show that all these functions are general recursive.

Problem 579

Show that the function F(x)F(x) from Problem 547 on p. 168 is a g.r.f.

Hint. First show that the function g(x)=⟨F(x),F(x+1)⟩g(x)=\langle F(x), F(x+1)\rangle is a g.r.f. ⊛\circledast

?
Problem 580

Another function that allows one to number pairs of natural numbers looks like this: c(x,y)=2x(2y+1)−1c(x, y)=2^{x}(2 y+1)-1. Prove that cc itself and the inverse functions c1c_{1} and c2c_{2} to it (that is, c1(c(x,y))=xc_{1}(c(x, y))=x and c2(c(x,y))=yc_{2}(c(x, y))=y) are general recursive. ⊛\circledast

?
Problem 581

Given a one-to-one numbering of pairs kk (for example, from Problems 578 or 580), one can inductively number ordered nn-tuples of arbitrary length:

K()=0K(x1,…,xn,xn+1)=k(k(k1(K(x1,…,xn)),xn+1),n+1) \begin{aligned} K() & =0 \\ K\left(x_{1}, \ldots , x_{n}, x_{n+1}\right) & =k\left(k\left(k_{1}\left(K\left(x_{1}, \ldots , x_{n}\right)\right), x_{n+1}\right), n+1\right) \end{aligned}
?
(a)

Prove that the function KK is one-to-one.

(b)

Prove that the functions K(n)(x1,…,xn)K^{(n)}\left(x_{1}, \ldots , x_{n}\right) are general recursive.

(c)

Prove that the inverse function K′K^{\prime } to KK is also general recursive: ⊛\circledast

K′(K(x0,…,xn),m)={xm, for m⩽n,0, otherwise.  K^{\prime }\left(K\left(x_{0}, \ldots , x_{n}\right), m\right)= \begin{cases} x_{m}, & \text{ for } m \leqslant n, \\ 0, & \text{ otherwise. }\end{cases}
Problem 582

Yet another way of coding finite sequences of natural numbers uses binary notation: the sequence (n0,n1,…,nk)\left(n_{0}, n_{1}, \ldots , n_{k}\right) is coded by the binary number 1nk01nk−10…01n101n01^{n_{k}} 01^{n_{k-1}} 0 \ldots 01^{n_{1}} 01^{n_{0}} (sequences that arise from one another by adding or removing trailing zeros are not distinguished).

?
(a)

Find the codes of the sequences (2,3,0,1)(2,3,0,1) and (0,0,2,1,2)(0,0,2,1,2).

(b)

Determine of which sequences the numbers 169 and 19783 are codes.

(c)

Prove that the function k(x,y)k(x, y) is general recursive. Here xx is the code of a sequence, yy is the index of an element, and the value of the function equals that element. ⊛\circledast

Problem 583

The Ackermann function is defined as follows:

A(0,y)=y+1A(x+1,0)=A(x,1)A(x+1,y+1)=A(x,A(x+1,y)) \begin{aligned} A(0, y) & =y+1 \\ A(x+1,0) & =A(x, 1) \\ A(x+1, y+1) & =A(x, A(x+1, y)) \end{aligned}
?
(a)

Find A(1,y)A(1, y) and A(2,y)A(2, y) for all natural yy.

(b)

Prove that A(3,y)=2y+3−3A(3, y)=2^{y+3}-3.

(c)

Prove that the Ackermann function is general recursive. Hint. Using the functions KK and K′K^{\prime } (Problem 581 on the facing page), construct sequences (x1,x2,…,xn,z)(x_{1}, x_{2}, \ldots , x_{n}, z) such that ⊛\circledast

A(x,y)=A(x1,A(x2,…,A(xn,z)…)). A(x, y)=A\left(x_{1}, A\left(x_{2}, \ldots , A\left(x_{n}, z\right) \ldots \right)\right).