We often encounter a definition of a function over the natural numbers such as

f (0, m ) = 0

f ( n + 1, m ) = f ( n , m ) + m

Is this a legitimate definition? That is, is there really a function that satisfies the above two equalities for all n and m ? And if so, is there only one such function, or is the definition ambiguous? We address this question in this section through a somewhat more general related question.

images    1.7.0.24 Example. Let us look at a simpler question than the above and see if we can produce a good answer. First off, is there a function g given by the following two equalities for all values of n ?

g (0) = 1

g ( n + 1) = 2 g ( n )

Well, let’s see: By induction on n we can show that g ( n ) ↓ for all n : Indeed, this is true for n = 0 by the first equality. Taking the I.H. that g ( n ) ↓ (for a fixed unspecified n ) we can compute g ( n + 1) so indeed

g ( n ) ↓ for all n

We can say then that the function g exists; right?

Wrong ! A function is a set, in this case an infinite table of pairs (if we take its existence for granted). We did not show that it exists as a table of pairs; rather we have only shown that

If a g satisfying the given equalities exists, then it is total . 45

We can however prove that any two functions satisfying the equalities must be equal. That is, if h is another such function, then h = g or, on an input by input basis,

images

Note that we wrote = in (1), rather than ≃ (cf. 1.2.0.11 ), since we already know that if a function satisfies the given equalities, then it is total .

As for (1), for n = 0 we are done by the first equality. Taking as I.H. the case for some fixed n , the case for n + 1 is easily settled: g ( n +1) = 2 g ( n ) \= 2 h ( n ) \= h ( n +1), where the middle = is due to the I.H.   Image

So how do we settle existence? We build a function f (or g ) given as above either iteratively, by stages [which is the usual approach in the literature, when done correctly; cf. Tourlakis (1984)] or as a closure; a set of the form C1( Image , Image ) for appropriate Image , Image . The latter approach is from Tourlakis (2003b), which also develops the iterative approach. Mindful of the example in 1.6.0.19 , we will define functions recursively on an inductively defined set C1( Image , Image ) that is given via an unambiguous pair Image , Image .

1.7.0.25 Theorem. (Function definition by recursion) Let Image , Image be an unambiguous pair and C1( Image , Image ) ⊆ A , for some set A. Let h : Image → B and g R : A × B r → B , for each r-ary R Images Image , be given functions . 46

Under these assumptions, there is a unique function f : C1( Image , Image ) → B such that

images

The reader may wish to postpone studying this proof, but he should become thoroughly familiar with the statement of the theorem, and study the examples that follow the proof.

images    Proof . To prove the existence of a “solution” f to the given recursive definition (1), we will build a single-valued binary relation F ⊆ A × B, which, when we rewrite F ( x, y ) as “ y = F ( x )”—with y as the output variable—satisfies (1) above. To build it, we will realize it as an appropriate C1( Image , Image ), for appropriately chosen initial set Image and set of rules Image .

For each r -ary rule R Images Image , define the r -ary rule Image by

images

images   For any a 1 ,..., a r , b, the above definition of Image is effected for all possible choices of o 1 ,..., o r in B for which g R ( b , o 1 ,..., o r ) is defined.

By the way, there is no mystery in the definition of Image (the name chosen to show the close association with R ): If we anticipate that (1) does have an f -solution, we can then view the o i as the f ( a i ). Then Image ’s job is—once we give it, in the form of input/output pairs, where the outputs are those of f on all the i.p. of b —to compute f ( b ) using g R and to output the input/output pair Images b , f ( b )) Images .   images

Collect now all the rules Image as defined, to form the rule-set Image .

As the initial objects-set Image , which we will associate with the rule-set Image , we take Image = h —that is, Images x, , y Images Images Image iff h ( x ) = y .

Claim 1. The set F = C1( Image , Image ) is a single-valued binary relation C1( Image , Image ) → B .

Proof of Claim 1 . First off, that F ⊆ C1( Image , Image ) × B is immediate: Image ⊆ C1( Image , Image ) × B , and each relation of Image has as output a pair in C1( Image , Image ) × B , by definition (2).

We next establish that F is single valued in its second component, doing induction over C1( Image , Image ). The claim to prove will be

images

Basis: Suppose that Images a , b Images Images Image and let also Images a , c Images Images F .

By 1.6.0.15 , the latter entails, in principle:

(i) Images a , c Images Images Image . Then c = h ( a ) = b ,

OR,

(ii) for some r -ary Image Images Image , we have Image ( Images a 1 , o 1 Images ,..., Images a r , o r Images , Images a , c Images ), where R ( a 1 ,..., a r , a ), c = g R ( a , o 1 ,..., o r ), and Images a 1 , o 1 Images ,..., Images a r , o r Images are in F .

The right hand side of the capitalized “or” cannot be applicable—due to its requirement that R ( a 1 , ..., a r , a )—given that a Images Image and ( Image , Image ) is unambiguous.

We next prove that the property (*) propagates with each Image . So, let

Image ( Images a 1 , o 1 Images , ..., Images a r , o r Images , Images a , b Images )

Since by the previous argument Images , let also

images

where Q ( a 1 ,..., a r , a ) and P ( Image ), but also [cf. (2)]

images

Since ( Image , Image ) is unambiguous, Q = P (hence also Image = Image ); thus r = l , and Image , for i = 1,..., r .

By I.H., Image , for i = 1,..., r , hence b = c by (3). End of proof: Claim 1 .

Claim 2. F satisfies (1). Now that we know that F is a function we can write

b = F ( a ) for Images a , b Images Images F

Our task here is to show that if we replace the “(function) variable” f in (1) by the constructed F, the “iff” stated in (1) will hold.

(←) direction: We prove that the right hand side (rhs) of (1) implies the left, if the letter f is replaced throughout by F . The rhs is a disjunction, so we have two cases to consider [cf. 1.1.1.48(a) ]. First, let x Images Image and y = h ( x ). Since h = Image ⊆ F, we have that F ( x , y ) is true, that is, y = F ( x ).

Second, consider the complicated side of OR in (1): So let, for some R Images Image , y = g R ( x , o 1 ,..., o r ), where R ( a 1 ,..., a r , x ) and o i = F ( a i ), for i = 1,..., r .

By (2), Image ( Images a 1 , o 1 Images ,..., Images a r , o r Images , Images x , y Images ), thus— F being closed under all the rules in Image — Images x, y Images Images F; for short, y = F ( x ).

(→) direction Now we assume that F ( x, y ) holds. We want to infer the right hand side (of iff ) in (1)—with f replaced by F .

So let y = F ( x ). There are two cases according to 1.6.0.15 :

Case 1 . Images x , y Images Images Image . Thus (by Image = h ) y = h ( x ), and x Images Image (definition of Image ); the top case of (1).

Case 2 . Suppose next that Images x, y Images Images F because, for some Image , the following hold (see (2)):

(a) Image ( Images a 1 , o 1 Images ,..., Images a r , o r Images , Images x , y Images )

(b) Q ( a 1 ,..., a r , x )

(c) y = g Q ( x , o 1 ,..., o r )

(d) All of Images a 1 , o 1 Images ,..., Images a r , o r Images are in F

By (d), o i = F ( a i ), for i = 1,..., r . But then the conjunction of the foregoing observation with (b) and (c) is the right hand side of the OR; as needed. End of proof: Claim 2 .

Uniqueness of F . Let the function K also satisfy (1). We show by induction over C1( Image , Image ) that

images

(→) Let x Images Image , and y = F ( x ). By lack of ambiguity, x has no i.p. Thus, y = h ( x ). But then, y = K ( x ), since K satisfies (1).

Let now Q ( a 1 ,..., a r , x ) and y = F ( x ). By (1), there are (unique, as we now know) o 1 ,..., o r such that o i = F ( a i ), for i = 1,..., r , and y = g Q ( x , o 1 ,..., o r ). By the I.H., o i = K ( a i ). As K satisfies (1), y = K ( x ).

(←) The roles of the letters F and K in the above argument being symmetric, we need say no more. Image

The above formulation with the so-called “graphs” of the utilized functions—a term applying to the relation y = f ( x ) 47 —rather than writing, say,

images

appears to be unnecessarily cumbersome. Cumbersome, yes, but not “unnecessarily”:

In the used formulation, by keeping an eye on both the input and output sides at once, we took care of the partial function case ( total or not ) without having to worry about points of undefinition of the defined function or to use Kleene equality. In fact, using “=” above is incorrect in the nontotal case.   images

1.7.0.26 Example. Referring back to Example 1.7.0.24 , we see that the defined by recursion g exists (and is, of course, unique): It is defined over the set Image = C1({0}, { S }), where I denoted by S the successor rule:

S ( x , x + 1), for all x in Image

The rule is clearly unambiguous, so Theorem 1.7.0.25 applies. Image

1.7.0.27 Example. Fix n > 0 from Image and consider the rule R below

R ( Images x , Image n Images , Images x + 1, Image n Images ), for all x , y i in Image

and form Image n , = C1( Image ,{R}), where Image = { Images 0, Image n Images : for all y i in Image }.

The rule R is clearly unambiguous: every Images x , y n Images is either initial or has the unique i.p. Images x – 1, y n Images . Thus Theorem 1.7.0.25 applies— Image n = Image n +1 , of course—and enables recursive definitions like the following, based on two given functions h and g from Image n and Image n +1 × B respectively to some set B, to produce unique f -solutions.

images

As is usual, we listed the arguments, e.g., in f , in their proper order, however omitting the Images ... Images brackets.

The above recurrence is the primitive recursion schema of Kleene, and it will play quite an active role in the next chapter. It is customary to write the schema in this form:

f (0, Image n ) ≃ h ( Image n )              

f ( x + 1, Image n ) ≃ g ′( x , Image n , f ( x , Image n ))

where g ′ is g, but modified to accept input x rather than x + 1 in the first argument slot.

Incidentally, the recursion given at the very opening of this section—taking there B = Image —fits the primitive recursion schema above, so the function it defines exists and is unique. The reader will immediately recognise that the function defined there is multiplication, n × m . Image

1.7.0.28 Exercise. Prove that if h and g are total, then so is f defined by (1) above, so we can replace ≃ by =. Image

images    1.7.0.29 Example. What about a recursion like this, where we still take our inputs (of f ) from Image ?

images

Before we answer this, a few comments on intentions, and notation. We intend that the value f ( x , Image n ) is computed based on our knowledge of the entire history of values of f —or course-of-values [Kleene (1952)1—at the set of all previous “points”

images

As we can have no functions of a variable number of arguments, we have tentatively grouped the entire history into a single set -argument. It turns out that it is more profitable to use a set of pairs of inputs and outputs (of f ) rather than just outputs in the recursive call embedded in g above, since such pairs can naturally handle nontotal functions—the pair Images a , f ( a ) Images is listed if f ( a ) ↓.

images

The switch to g ′ from g reflects the modification to the x -argument and to the set-argument.

Now, if we call the set (1) “ S x − 1, Image n ” for the sake of convenience, we may rewrite the above recurrence more correctly, and without “...”, as

images

images

Here is now why the recurrence (2)–(3) has a unique f -solution: Let us write H ( x , Image n ) as an abbreviation of f Image S x , Image n . We can then have—using (2)–(3)—a (simple) primitive recursion (as in 1.7.0.27 ) for H :

images

images

A unique H exists that satisfies (4)–(5), by 1.7.0.27 . But f ( x , Image n ) ≃ H ( x , Image n ) Image x , Image n Image for all x , Image n ; so f exists and is unique. 48

Given that H ( x , Image n ) = f Image S x , Image n —a single-valued table of tuples—we see that evaluating H ( x , Image n ) at Images i , Image n Images , for i = 0, 1,..., x, we end up with the output (if it exists) of f at input Images i , Image n Images . That is, the expression “ H ( x , Image n ) ( x , Image n )” above makes sense, and, when defined, teases out f ( x , Image n ).

If we work strictly within arithmetic—that is, we allow no set arguments, in particular—then one neat way to deal with a sequence of numbers is to code them by a single number . Applying this trick reduces once again the original recursion to the standard schema of Example 1.7.0.27 . This approach has additional important side benefits and we will revisit it in the next chapter.   Image

1.7.0.30 Example. Let A = {1, 2}. In this example we consider only functions with inputs from A * and outputs in A *. Suppose that h, g 1 and g 2 are such given functions of n for the first and n + 2 variables for the other two. The recursion (for fixed n > 0)

f ( Image , Image n )      ≃ h ( Image n )
f ( x * 1, Image n ) ≃ g 1 ( x , Image n , f ( x , Image n ))
f ( x * 2, Image n ) ≃ g 2 ( x , Image n , f ( x , Image n ))

is called right primitive recursion on notation —“right” since we change x by concatenating a 1 or 2 to its right; “on notation” since we are thinking in terms of the notation rather than value of x when we increment it.

Given the h and the g i there is a unique f that satisfies the three equalities above, for all x , Image n . To apply Theorem 1.7.0.25 we define Image as C1 ( Image , Image ) where Image has two rules,

R 1 ( Images x , Image n Images , Images x * 1, Image n Images ), for all x , Image n in A *

and

R 2 ( Images x , Image n Images , Images x * 2, Image n Images ), for all x , Image n in A *

We define Image as { Images Image , Image n Images : for all y i in A *}.

Clearly the pair Image , Image is unambiguous and 1.7.0.25 applies to the recursion on notation schema above, proving existence and uniqueness of f .

One can similarly utilize left recursion on notation, going from x to i * x , for i = 1 or i = 2.   images