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.
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,
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.
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(
,
) for appropriate
,
. 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(
,
) that is given via an unambiguous pair
,
.
1.7.0.25 Theorem. (Function definition by recursion) Let
,
be an unambiguous pair and C1(
,
) ⊆ A , for some set A. Let h :
→ B and g R : A × B r → B , for each r-ary R
, be given functions . 46
Under these assumptions, there is a unique function f : C1(
,
) → B such that
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.
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(
,
), for appropriately chosen initial set
and set of rules
.
For each r -ary rule R
, define the r -ary rule
by
For any a 1 ,..., a r , b, the above definition of
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
(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
’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
b , f ( b ))
.
Collect now all the rules
as defined, to form the rule-set
.
As the initial objects-set
, which we will associate with the rule-set
, we take
= h —that is,
x, , y
iff h ( x ) = y .
Claim 1. The set F = C1(
,
) is a single-valued binary relation C1(
,
) → B .
Proof of Claim 1 . First off, that F ⊆ C1(
,
) × B is immediate:
⊆ C1(
,
) × B , and each relation of
has as output a pair in C1(
,
) × B , by definition (2).
We next establish that F is single valued in its second component, doing induction over C1(
,
). The claim to prove will be
Basis: Suppose that
a , b
and let also
a , c
F .
By 1.6.0.15 , the latter entails, in principle:
(i)
a , c
. Then c = h ( a ) = b ,
OR,
(ii) for some r -ary
, we have
(
a 1 , o 1
,...,
a r , o r
,
a , c
), where R ( a 1 ,..., a r , a ), c = g R ( a , o 1 ,..., o r ), and
a 1 , o 1
,...,
a r , o r
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
and (
,
) is unambiguous.
We next prove that the property (*) propagates with each
. So, let
(
a 1 , o 1
, ...,
a r , o r
,
a , b
)
Since by the previous argument
, let also
where Q ( a 1 ,..., a r , a ) and P (
), but also [cf. (2)]
Since (
,
) is unambiguous, Q = P (hence also
=
); thus r = l , and
, for i = 1,..., r .
By I.H.,
, 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
a , b
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
and y = h ( x ). Since h =
⊆ 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
, 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),
(
a 1 , o 1
,...,
a r , o r
,
x , y
), thus— F being closed under all the rules in
—
x, y
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 .
x , y
. Thus (by
= h ) y = h ( x ), and x
(definition of
); the top case of (1).
Case 2 . Suppose next that
x, y
F because, for some
, the following hold (see (2)):
(a)
(
a 1 , o 1
,...,
a r , o r
,
x , y
)
(b) Q ( a 1 ,..., a r , x )
(c) y = g Q ( x , o 1 ,..., o r )
(d) All of
a 1 , o 1
,...,
a r , o r
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(
,
) that
(→) Let x
, 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.
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,
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.
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
= C1({0}, { S }), where I denoted by S the successor rule:
S ( x , x + 1), for all x in
The rule is clearly unambiguous, so Theorem 1.7.0.25 applies.
1.7.0.27 Example. Fix n > 0 from
and consider the rule R below
R (
x ,
n
,
x + 1,
n
), for all x , y i in
and form
n , = C1(
,{R}), where
= {
0,
n
: for all y i in
}.
The rule R is clearly unambiguous: every
x , y n
is either initial or has the unique i.p.
x – 1, y n
. Thus Theorem 1.7.0.25 applies—
n =
n +1 , of course—and enables recursive definitions like the following, based on two given functions h and g from
n and
n +1 × B respectively to some set B, to produce unique f -solutions.
As is usual, we listed the arguments, e.g., in f , in their proper order, however omitting the
...
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,
n ) ≃ h (
n )
f ( x + 1,
n ) ≃ g ′( x ,
n , f ( x ,
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 =
—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 .
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 =.
1.7.0.29 Example. What about a recursion like this, where we still take our inputs (of f ) from
?
Before we answer this, a few comments on intentions, and notation. We intend that the value f ( x ,
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”
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
a , f ( a )
is listed if f ( a ) ↓.
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,
n ” for the sake of convenience, we may rewrite the above recurrence more correctly, and without “...”, as
Here is now why the recurrence (2)–(3) has a unique f -solution: Let us write H ( x ,
n ) as an abbreviation of f
S x ,
n . We can then have—using (2)–(3)—a (simple) primitive recursion (as in 1.7.0.27 ) for H :
A unique H exists that satisfies (4)–(5), by 1.7.0.27 . But f ( x ,
n ) ≃ H ( x ,
n )
x ,
n
for all x ,
n ; so f exists and is unique. 48
Given that H ( x ,
n ) = f
S x ,
n —a single-valued table of tuples—we see that evaluating H ( x ,
n ) at
i ,
n
, for i = 0, 1,..., x, we end up with the output (if it exists) of f at input
i ,
n
. That is, the expression “ H ( x ,
n ) ( x ,
n )” above makes sense, and, when defined, teases out f ( x ,
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.
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 (
,
n ) ≃ h (
n )
f ( x * 1,
n ) ≃ g 1 ( x ,
n , f ( x ,
n ))
f ( x * 2,
n ) ≃ g 2 ( x ,
n , f ( x ,
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 ,
n . To apply Theorem 1.7.0.25 we define
as C1 (
,
) where
has two rules,
R 1 (
x ,
n
,
x * 1,
n
), for all x ,
n in A *
and
R 2 (
x ,
n
,
x * 2,
n
), for all x ,
n in A *
We define
as {
,
n
: for all y i in A *}.
Clearly the pair
,
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.