• Keine Ergebnisse gefunden

Closure Properties

This section provides a small repository of algorithmic properties and constructions for later use.

Transformation of Variables and Parametrization

Given a function f : Nn0 → N0 and a mapping φ : [n] → [m]. The function fφ obtained from f by transformation of variables with respect toφis defined as

fφ:Nm0 →N0: (x1, . . . , xm)7→f(xφ(1), . . . , xφ(n)). (2.12) Proposition 2.18.If the functionf is primitive recursive, the functionfφ is also primitive recursive.

Proof. Transformation of variables can be described by the composition

fφ=f(π(m)φ(1), . . . , πφ(n)(m)). (2.13)

⊔ Examples 2.19.Three important special cases for dyadic functions:

• Permutation of variables:fφ: (x, y)7→f(y, x), whereφ: [2]→[2] : (a, b)7→(b, a).

• Adjunct of variables: fφ: (x, y)7→f(x), whereφ: [2]→[1] : (a, b)7→a.

• Identification of variables: fφ:x7→f(x, x), where φ: [1]→[2] :a7→(a, a).

♦ Letc(k)i denote thek-ary constant function with valuei∈N0, i.e.,

c(k)i :Nk0→N0: (x1, . . . , xk)7→i. (2.14) Proposition 2.20.The constant functionc(k)i is primitive recursive.

Proof. Ifk= 0, c(0)ii◦c(0)0 . Otherwise,c(k)ii◦c(1)0 ◦π(k)1 . ⊓⊔ Letf :Nn0 →N0 be a function. Take a positive integerm withm < nanda= (a1, . . . , am)∈Nm0. The functionfaobtained fromf byparametrization with respect toais defined as

fa:Nn−m0 →N0: (x1, . . . , xn−m)7→f(x1, . . . , xn−m, a1, . . . , am). (2.15) Proposition 2.21.If the functionf is primitive recursive, the functionfa is also primitive recursive.

Proof. Parametrization can be described by the composition

fa=f(π1(n−m), . . . , π(n−m)n−m , c(n−m)a1 , . . . , c(n−m)am ). (2.16)

2.3 Closure Properties 17

The functionf is clearly total and said to bedefined by cases.

Proposition 2.22.If the above functionsgi andhi,1≤i≤r, are primitive recursive, the function f is also primitive recursive.

Proof. The functionf is given as follows, f =

Example 2.23.Consider the monadic functionf :N0→N0 defined by f(x) = and thebounded product off is the function

Πf :Nk+10 →N0: (x1, . . . , xk, y)7→

Yy

i=0

f(x1, . . . , xk, i). (2.21)

Proposition 2.24.If the functionf is primitive recursive, the functionsΣf andΠf are also primitive recursive.

Proof. The functionΣf is given as

Σf(x,0) =f(x,0) and Σf(x, y+ 1) =Σf(x, y) +f(x, y+ 1). (2.22) This corresponds to the primitive recursive schemeΣf = pr(g, h), whereg(x) =f(x,0) andh(x, y, z) =

+(f(x, ν(y)), z). The functionΠf can be similarly defined. ⊓⊔

Example 2.25.Take the functionf :N0 →N0 defined byf(x) = 1 if x= 0 andf(x) =xif x >0.

This function defined by cases is primitive recursive and thus the bounded product (factorial function), given byΠf(x) =x! for allx∈N0, is primitive recursive as well. ♦ Bounded Minimalization

Letf :Nk+10 →N0 be a total function. Thebounded minimalization off is the function

µf :Nk+10 →N0: (x, y)7→µ(i≤y)[f(x, i) = 0], (2.23) where for each (x, y)∈Nk+10 ,

µ(i≤y)[f(x, i) = 0] =

j ifj = min{i|0≤i≤y∧f(x, i) = 0}exists,

y+ 1 otherwise. (2.24)

That is, the valueµf(x, y) provides the smallest indexj with 0≤j≤ysuch thatf(x, j) = 0. If there is no such index, the value is y+ 1. In this way, bounded minimalization can be viewed as a bounded search process.

Proposition 2.26.If the functionf is primitive recursive, the functionµf is also primitive recursive.

Proof. By definition,

µf(x,0) = sgn(f(x,0)) (2.25)

and

µf(x, y+ 1) =

µf(x, y) ifµf(x, y)≤y orf(x, y+ 1) = 0,

y+ 2 otherwise. (2.26)

Define thek+ 2-ary functions

g1: (x, y, z)7→z, g2: (x, y, z)7→y+ 2,

h1: (x, y, z)7→(z−˙ y)·sgn(f(x, y+ 1)), h2: (x, y, z)7→csg(h1(x, y, z)).

(2.27)

These functions are primitive recursive. Moreover, the functions h1 and h2 provide a partition ofN0. Thus the following function defined by cases is also primitive recursive:

2.3 Closure Properties 19

g(x, y, z) =

g1(x, y, z) ifh1(x, y, z) = 0,

g2(x, y, z) ifh2(x, y, z) = 0. (2.28) We have h1(x, y, µf(x, y)) = 0 if and only if (µf(x, y)) ˙−y)·sgn(f(x, y+ 1)) = 0, which is equivalent to µf(x, y)) ≤ y or f(x, y+ 1) = 0. In this case, g1(x, y, µf(x, y)) = µf(x, y+ 1). The other case can be similarly evaluated. It follows that the bounded minimalizationµf corresponds to the primitive recursive schemeµf = pr(s, g), where s:Nk0 →N0 is defined as s(x) = sgn(f(x,0)) and g is given as

above. ⊓⊔

Example 2.27.Consider the integral division function

÷:N20→N0: (x, y)7→

⌊x/y⌋ify >0,

x ify= 0, (2.29)

where the expression⌊x/y⌋means that⌊x/y⌋=z ify·z≥xandz is minimal with this property.

The function ÷ is defined by cases. In view of the case y > 0, the value z can be calculated by bounded minimalization. In this way, the integral division function is given by

÷(x, y) =µ(z≤x)[y·z−˙ x= 0]·sgn(y) +x·csg(y), x, y∈N0.

The associated remainder function given by rem(x, y) =y· ÷(x, y) ˙−xif y >0 and rem(x, y) = 0 if

y= 0 and is therefore also primitive recursive. ♦

Iteration

Thepowers of a functionf :N0→N0are inductively defined as

f0= idN0 and fn+1=f◦fn, n≥0. (2.30) In particular, f1 =f ◦f0 = f ◦idN0 =f. The iteration of a function f : N0 → N0 is given by the function

g:N20→N0: (x, y)7→fy(x). (2.31) Example 2.28.Consider the function f : N0 → N0 : x 7→ 2x. The iteration of f is the function

g:N20→N0defined by g(x, y) = 2y·x. ♦

Proposition 2.29.If f is a monadic primitive recursive function, the iteration off is also primitive recursive.

Proof. The iterationg off follows the primitive recursive scheme

g(x,0) =x (2.32)

and

g(x, y+ 1) =f(g(x, y)) =f◦π3(3)(x, y, g(x, y)), x, y∈N0. (2.33)

Iteration can also be defined for multivariate functions. For this, let f : Nk0 → Nk0 be a function defined by coordinate functionsfi :Nk0→N0, 1≤i≤k, as follows:

f(x) = (f1(x), . . . , fk(x)), x∈Nk0. (2.34) Writef = (f1, . . . , fk) and define thepowers off inductively as follows:

f0(x) =x and fn+1(x) = (f1(fn(x)), . . . , fk(fn(x))), x∈Nk0. (2.35) These definitions give immediately rise to the following result.

Proposition 2.30.If the functions f = (f1, . . . , fk) are primitive recursive, the powers of f are also primitive recursive.

Theiteration off = (f1, . . . , fk) is defined by the functions

gi:Nk+10 →N0: (x, y)7→(πi(k)◦fy)(x), 1≤i≤k. (2.36) Proposition 2.31.If the functionsf = (f1, . . . , fk)are primitive recursive, the iteration of f is also primitive recursive.

Proof. The iteration off = (f1, . . . , fk) follows the primitive recursive scheme

gi(x,0) =xi (2.37)

and

gi(x, y+ 1) =fi(fy(x)) =fi◦π(k+2)k+2 (x, y, gi(x, y)), x∈Nk0, y∈N0, 1≤i≤k. (2.38)

Pairing Functions

A pairing function encodes the pairs of natural numbers by single natural numbers. A primitive recursive bijection fromN20ontoN0 is called apairing function. In set theory, any pairing function can be used to prove that the rational numbers have the same cardinality as the natural numbers. For instance, the Cantor function J2:N20→N0is defined as

J2(m, n) =

m+n+ 1 2

+m. (2.39)

This function will provide a proof that the cartesian product N20 is denumerable. To this end, write down the elements ofN20 in a table as follows:

(0,0) (0,1) (0,2) (0,3) (0,4). . . (1,0) (1,1) (1,2) (1,3) . . . (2,0) (2,1) (2,2) . . . (3,0) (3,1) . . . (4,0) . . .

. . .

(2.40)

2.3 Closure Properties 21

For each numberk≥0, thek-th anti-diagonal in this table is given by the sequence

(0, k),(1, k−1), . . . ,(k,0). (2.41)

Now generate a list of all elements ofN20by writing down the anti-diagonals in consecutive order starting with the 0-th anti-diagonal:

(0,0),(0,1),(1,0),(0,2),(1,1),(2,0),(0,3),(1,2),(2,1),(3,0),(0,4), . . . . (2.42) Claim that the pair (0, m+n) is at position m+n+12

in the list. Indeed, the pair (0,0) lies at position 0 if we put 12

The pair (m, n) lies at positionmin the m+n-th anti-diagonal and therefore occurs in the list at positionJ2(m, n) = m+n+12

+m. This shows that the functionJ2is bijective.

Proposition 2.32.The Cantor functionJ2 is primitive recursive.

Proof. By using the integral division function÷, one obtains

J2(m, n) =÷((m, n)·(m+n+ 1),2) +m. (2.43)

ThusJ2 is primitive recursive. ⊓⊔

The Cantor functionJ2can be inverted by taking coordinate functions K2, L2:N0→N0such that J2−1(n) = (K2(n), L2(n)), n∈N0. (2.44)

Proposition 2.34.The coordinate functionsK2 andL2 are primitive recursive and the pair (K2, L2) is the inverse of J2.

Proof. Letn∈N0. The corresponding numbersin (2.45) can be determined by bounded minimalization as follows:

µ(i≤n)[n−˙ 1

2s(s+ 1) = 0] =

j ifj= min{i|i≤y∧n−˙ 12i(i+ 1) = 0} exists,

n+ 1 otherwise. (2.49)

The valuej always exists and we have s=

j ifn= 12j(j+ 1),

j−˙ 1 otherwise. (2.50)

ThenK2(n) =n− ÷(s(s+ 1),2) andL2(n) =s−K2(n). Thus both,K2andL2are primitive recursive.

Finally, by (2.46) and (2.48),J2(K2(n), L2(n)) =J2(m, s−m−1) = 12s(s+ 1) +m=nand so (2.44)

follows. ⊓⊔

This assertion implies that the Cantor functionJ2is a pairing function.