• Keine Ergebnisse gefunden

2.(x, y+ 1)∈ dom(f) if and only if (x, y) ∈ dom(f) and (x, y, f(x, y))∈ dom(h) for all x∈ Nn0, y∈N0,

3.f(x,0) =g(x)for all x∈dom(f), and

4.f(x, y+ 1) =h(x, y, f(x, y))for all (x, y+ 1)∈dom(f).

The proof makes use of the fundamental lemma. The partial function f defined by g and h in this proposition is also denoted byf = pr(g, h) and said to be defined byprimitive recursion ofgalongh.

Proposition 2.16.The class of URM computable functions is closed under primitive recursion; that is, ifg:Nn0 →N0 andh:Nn+20 →N0 are URM computable,f = pr(g, h)is URM computable.

Primitively Closed Function Classes LetF be a class of functions, i.e.,

F ⊆ [ n≥1, and is closed under composition and primitive recursion.

LetP denote the class of all primitive recursive functions,TURM the class of all URM computable total functions, andT the class of all total functions.

Proposition 2.17.The classesP,TURM, andT are primitively closed.

In particular, the classP of primitive recursive functions is the smallest class of functions which is primitively closed. Indeed, we have The concept of primitive closure carries over to partial functions, since composition and primitive recursion have been defined for partial functions as well. LetFURMdenote the class of URM computable functions andF the class of all functions.

Proposition 2.18.The classesFURM andF are primitively closed.

The classes of functions (under inclusion) introduced in this chapter are given by the Hasse diagram in Fig. 2.1. All inclusions are strict. Indeed, the strict inclusionsTURM⊂ FURMandT ⊂ Fare obvious, while the strict inclusionsTURM⊂ T andFURM⊂ Ffollow by counting arguments. However, the strict inclusion P ⊂ TURM is not clear at all. An example of a total URM computable function that is not primitive recursive will be given in Chapter 4.

2.3 Closure Properties

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

F

T

②②

②②

②②

②②

② FURM

■■■■■■

■■■■

TURM

✉✉

✉✉

✉✉

✉✉

❊❊❊❊❊❊❊❊

P

Fig. 2.1. Classes of functions.

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.19.If a functionf is primitive recursive, the function fφ is also primitive recursive.

Proof. Transformation of variables can be described by the composition

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

⊔ Examples 2.20.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.21.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)

2.3 Closure Properties 17

Proposition 2.22.If a functionf is primitive recursive, the function fais 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)

⊔ Example 2.23.Letf :N50→N0. Takinga= (5,3) givesfa(x1, x2, x3) =f(x1, x2, x3,5,3). ♦ Definition by Cases

Lethi:Nk0→N0, 1≤i≤r, be total functions with the property that for eachx∈Nk0 there is a unique indexi∈[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.24.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 =

Xr

i=1

gi·(csg◦hi). (2.18)

Indeed, letx∈Nk0. Then there is exactly one indexj, 1≤j ≤r, such thatx∈Hj. By definition, we havehj(x) = 0 andhi(x)6= 0 for alli6=j, 1≤i≤r. It follows thatf(x) =Pr

i=1gi(x)·(csg◦hi(x)) =

gj(x)·(csg◦hj(x)) =gj(x), as claimed. ⊓⊔

Example 2.25.Consider the monadic functionf :N0→N0 defined by f(x) =

2xifx >0,

1 otherwise. (2.19)

The cases are defined by the partition given by the sets H1 ={x∈N0 | x >0} andH2 ={0}, and the corresponding mappings h1= csg and h2= 1−csg = sgn, respectively. Moreover,g1(x) = 2xand g2(x) = 1 for each x∈N0. In this way, we obtain for eachx∈N0,f(x) =g1(x)·(csg◦h1(x)) +g2(x)·

(csg◦h2(x)) =g1(x)·sgn(x) +g2(x)·csg(x). ♦

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.26.If a 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. ⊓⊔

Examples 2.27.Consider the identity function f : N0 → N0 : x 7→ x (with k = 0). This function is primitive recursive, since f(x) = x·sgn(x) for all x ∈ N0. Thus the bounded sum Σf (binomial coefficient) given by

Σf(0) = 0 and Σf(x) = Xx

i=0

f(i) = x+ 1

2

, x≥1, is also primitive recursive.

Take the function f : N0 →N0 (with k= 0) defined by f(x) = 1 if x= 0 and f(x) =xif x >0.

This function defined by cases is primitive recursive,

f(x) = csg(x) +x·sgn(x), x∈N0. Thus the bounded product (factorial function)Πf given by

Πf(x) = Yx

i=0

f(i) =x!, x∈N0,

is also 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)

2.3 Closure Properties 19 is no such index, the value is y+ 1. In this way, bounded minimalization can be viewed as a bounded search process.

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

Proof. By definition,

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

where the expression⌊y/x⌋is the largest number z such thatz ≤y/x. This function can be modified to yield the integral division function. On the other hand, the dyadic function

f(x, y) =µ(z≤y)[x·z−˙ y= 0]

is the zero function, since we havex·0 ˙−y= 0 for allx, y ∈N0. ♦ Iteration

Thepowers of a functionf :N0→N0are inductively defined as

f0= idN0 and fn+1=f◦fn, n≥0. (2.29) 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.30) Example 2.30.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.31.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, x∈N0, (2.31)

and

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

⊔ 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.33) 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.34) These definitions give immediately rise to the following result.

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

2.3 Closure Properties 21

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

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

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

(0, k),(1, k−1), . . . ,(k,0). (2.40) 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.41) 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.34.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.42)

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.43) In order to define them, taken∈N0. Find a numbers≥0 such that

1

2s(s+ 1)≤n < 1

2(s+ 1)(s+ 2) (2.44)

and put

m=n−1

2s(s+ 1). (2.45)

Then

m=n−1

2s(s+ 1)≤[1

2(s+ 1)(s+ 2)−1]−[1

2s(s+ 1)] =s. (2.46) Finally, set

K2(n) =m and L2(n) =s−m. (2.47)

Example 2.35.Let n = 17. Then 12s(s+ 1) ≤ 17 < 12(s+ 1)(s+ 2) is satisfied by s = 5. Thus

K2(17) = 2 andL2(17) = 3. Note thatJ2(2,3) = 17. ♦

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

Proof. Letn∈N0. The corresponding numbersin (2.44) can be determined by bounded minimalization µ(s≤n)[n−˙ 1

2s(s+ 1) = 0]. (2.48)

If n= 12s(s+ 1), thens is the value searched for. Otherwise, n < 12s(s+ 1) and the values searched for iss−1. ThenK2(n) =n−12s(s+ 1) andL2(n) =s−K2(n). Thus both, K2 andL2 are primitive recursive. Finally, by (2.45) and (2.47),J2(K2(n), L2(n)) =J2(m, s−m−1) = 12s(s+ 1) +m=nand

so (2.43) follows. ⊓⊔

This assertion implies that the Cantor functionJ2is a pairing function.