• 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.16.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.17.Three important special cases for dyadic functions:

• permutation of variables:fφ: (x, y)7→f(y, x),

• adjunct of variables:fφ: (x, y)7→f(x),

• identification of variables: fφ:x7→f(x, x).

♦ 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.18.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.19.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)

Definition by Cases

Lethi:Nk0→N0, 1≤i≤r, be total functions with the property that for eachx∈Nk0 there is a unique index i∈[r] such thathi(x) = 0. That is, the setsHi ={x∈Nk0 |hi(x) = 0} form a partition of the whole setNk0. Moreover, letgi :Nk0→N0, 1≤i≤r, be arbitrary total functions. Define the function

f :Nk0 →N0:x7→





g1(x) ifx∈H1, ... ... gr(x) ifx∈Hr.

(2.17)

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

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

Proof. In case ofr= 2, the functionf is given in prefix notation as follows:

f =g1·(csg◦h1) +g2·(csg◦h2). (2.18)

The general case follows by induction onr. ⊓⊔

Example 2.21.Let csg denote thecosign function, i.e., csg(x) = 0 ifx > 0 and csg(x) = 1 if x= 0.

The mappingsh1:x7→xmod 2 andh2:x7→csg(xmod 2) define a partition of the setN0into the set of even natural numbers and the set of odd natural numbers. These mappings can be used to define a function defined by cases as follows:

f(x) =

x/2 ifxis even,

(x+ 1)/2 ifxis odd. (2.19)

Bounded Sum and Product

Letf :Nk+10 →N0 be a total function. Thebounded sum off is the function Σf:Nk+10 →N0: (x1, . . . , xk, y)7→

Xy

i=0

f(x1, . . . , xk, i) (2.20) 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.22.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.23.Take the functionf :N0 →N0 defined byf(x) = 1 if x= 0 andf(x) =xif x >0.

This function is primitive recursive and thus the bounded product, given asΠf(x) =x! for allx∈N0,

is primitive recursive. ♦

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|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 isy+ 1.

Proposition 2.24.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:

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.25.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⌋=zify·z≥xandzis minimal with this property. Thus the valuezcan be provided by bounded minimalization. To this end, define the functionf :N30→N0: (x, y, z)7→csg(y·z−˙ x); that is,

f(x, y, z) =

0 ify·z > x,

1 otherwise. (2.30)

Applying bounded minimalization tof yields the primitive recursive function µf(x, y, z) =

smallestj≤zwith y·j > xifj exists,

z+ 1 otherwise. (2.31)

Identification of variables provides the primitive recursive function

(µf): (x, y)7→µf(x, y, x), (2.32)

which is given as

(µf)(x, y) =

smallest j≤xwithy·j > xify≥1,

x+ 1 ify= 0. (2.33)

It follows that÷(x, y) = (µf)(x, y) ˙−1. Finally, the remainder of xmoduloy is given by rem(x, y) =

y−˙ x· ÷(x, y) and thus is also primitive recursive. ♦

Pairing Functions

A pairing function uniquely encodes pairs of natural numbers by single natural numbers. A primitive recursive bijection from N20 onto N0 is called a pairing 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, theCantor function J2:N20→N0is defined as

J2(m, n) =

m+n+ 1 2

+m. (2.34)

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.35)

Itskth anti-diagonal is given by the sequence

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

Now generate a list of all elements ofN20 by writing down the anti-diagonals in a consecutive manner starting from 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.37) Note the kth anti-diagonal consists of k+ 1 entries. Thus the pair (m, n) lies at position m in the m+nth anti-diagonal and hence occurs in the list at position

[1 + 2 +. . .+ (m+n)] +m=

m+n+ 1 2

+m. (2.38)

That is,J2(m, n) provides the position of the pair (m, n) in the above list. This shows that the function J2 is bijective.

Proposition 2.26.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.39)

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.40)

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

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

This assertion implies that the Cantor functionJ2is a pairing function.

Iteration

Thepowers of a functionf :N0→N0are inductively defined as

f0= idN0 and fn+1=f◦fn, n≥0. (2.46) Theiteration of a functionf :N0→N0 is given by the function

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

g:N20→N0given byg(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.48)

and

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

⊔ 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.50) 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.51) These definitions immediately give 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.52) 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.53)

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.54)