Suppose that i codes a URM program, M , that acts on input variables x and y to compute a function λ xy . f ( x , y ). It is certainly trivial to modify program M to compute λ x . f ( x , a ) instead. In computer programming terms, we replace an instruction such as “read y ” by one that says “ y ← a ”.
In URM terms, since the input variables X 11, X 111, … are initialized before the computation starts, the way to implement the suggested “decommissioning” of y as an input variable—opting rather to initialize it with the number a explicitly, first thing during the computation—is to do the following, assuming x and y of f are mapped to X 11 and X 111 of M :
(1) Remove X 111 from the input variables list, X 11, X 111, and
(2) Modify M into M ′ by adding the instruction X 111 ← a as the very first instruction.
From the original code, i , a new code (depending on i and a ) can be easily calculated. This is the intuition of Kleene’s iteration or “S-m-n” theorem below.
The mathematical details are as follows.
2.6.0.31 Definition. (Code Concatenation)
2.6.0.32 Remark. Clearly, λ xy . x * y is primitive recursive. The definition’s aim is to achieve this—which it clearly does:
[ a 1 ,…, a n ] * [ b 1 ,…, b m ] = [ a 1 ,…, a n , b 1 ,…, b m ]
If Seq ( x ) or Seq ( y ) fail, then the result of x * y is irrelevant to us.
2.6.0.33 Exercise. What is 10 * 5?
2.6.0.34 Exercise. What is 1 * z ? z * 1?
2.6.0.35 Definition. (Concatenating URMs) Given two URMs M and N of codes m and n . We denote their concatenation by MN and m ⌢ n in terms of their codes. Note that MN means the superposition of the two URMs, in that order, with the stop -instruction removed from M and all the instructions of N adjusted to reflect that the first label of N now is lh ( m ).
We define m ⌢ n to be 0 if either of m or n is not a valid URM code.
2.6.0.36 Lemma. Let adj ( n , k ) (“ adjust n ”) be the expression that codes a URM n after k was added to all its instruction numbers (and all if-statements were adjusted to still transfer to the same instructions as before). Let also adj ( n , k ) = 0 if n does not code a URM. Then the function λ nk . adj ( n , k ) is primitive recursive.
Proof . First let us define a less ambitious function, f , that adjusts one instruction due to adding k to the instruction number:
Note that 231 = 3 · 7 · 11. Clearly, f
. Finally,
Clearly, adj is primitive recursive.
2.6.0.37 Lemma. λ mn.m ⌢ n is primitive recursive.
Proof .
The left hand operand of * above represents the removal of the stop -instruction of the URM m prior to concatenation. It is immediate from the above and the preceding lemma that λ mn.m ⌢ n is primitive recursive.
2.6.0.38 Theorem. (Kleene’s Iteration or “S-m-n” Theorem) For each m ≥ 1 and n ≥ 1, there is a primitive recursive function λ i
n .
( i ,
n ) such that, for all i ,
m ,
n ,
Proof. The construction of
is guided by the introductory remarks of this section: If i codes a URM M such that
then we remove the n variables X 1 m +2 ,…, X 1 m + n +1 from the designated input-variable list and add the instructions below at the top of program M.
X 1 m +2 ← y 1 , X 1 m +3 ← y 2 ,…, X 1 m + n +1 ← y n
To avail ourselves of the tools we have developed in this section, we implement the above plan by concatenating the following URM, N , to the left of M. Note that N is not normalized, but N M is, since M is.
The code for N is a function of
n (recall that m , n are constants) which we will name init (
n ). Referring to 2.3.0.2 ,
It is immediate that λ
n . init (
n ) is primitive recursive. Thus,
, given below for all i ,
n , is too by Lemma 2.6.0.37 .
It is important to note that (by 2.6.0.37 ) if i fails the U RM ( i ) “test”, then so does
( i ,
n ) (indeed, equals 0; cf. 2.6.0.37 ) and thus both sides of (1) are (Kleene-) completely equal (the empty function is undefined on all inputs).
2.6.0.39 Remark. (1) It is important to note by inspecting (2) and (3) in the proof above that if U RM ( i ) holds, then
is strictly increasing with respect to each y i variable. Of course, if U RM ( i ) fails, then
returns 0 no matter what the inputs y i may be.
(2) A note on notation: In
the upper index, m , is a mnemonic tool for how many variables stayed “up” (in the
argument), while the lower index, n , indicates how many variables were moved “down”, to be hardwired into the “program”
( i ,
n ) as it were.
These considerations led to the nickname of the iteration theorem as the “S-m-n theorem”.
(3) In practice, the S-m-n theorem is applied as follows: If λ
k y
r . f (
k , y ,
r )
, then there is a 1-1 h
, such that, for all
k , y ,
r , we have
By the assumption on f and 2.3.0.12 , there is an i
, such that f (
k , y ,
r ) ⋍
(
k ,
r , y ). Note the permutation of variables, where y was moved to the end of the argument list of
, to align with requirements of the S-m-n theorem. Can we do this? Yes, since we may chose the URM i such that we have mapped the variables
k , y ,
r of f to the “formal” variables X 11, … X 1 k + r +2 so that y ’s role is played by X 1 k + r +2 .
Pause. Is this the same as saying “use 2.1.2.6 (iii) to permute variables so that y is last”?
We take h = λ y .
( i , y ). Note that the italicized part, “a 1-1”, above is a weakening of the observation (1) above.