Bounded Summation is Primitive Recursive

Theorem
Let the function $$f: \N^{k+1} \to \N$$ be primitive recursive.

Then so is the function $$g: \N^{k+1} \to \N$$ defined as:
 * $$g \left({n_1, n_2, \ldots, n_k, z}\right) = \begin{cases}

0 & : z = 0 \\ \sum_{y=1}^z f \left({n_1, n_2, \ldots, n_k, y}\right) & : z > 0 \end{cases}$$

Proof
The function $$g$$ satisfies:
 * $$g \left({n_1, n_2, \ldots, n_k, z}\right) = 0$$;
 * $$g \left({n_1, n_2, \ldots, n_k, z+1}\right) = g \left({n_1, n_2, \ldots, n_k, z}\right) + f \left({n_1, n_2, \ldots, n_k, z + 1}\right)$$.

Hence $$g$$ is defined by primitive recursion from:
 * the primitive recursive function $\operatorname{add}$;
 * $$f$$, which is primitive recursive;
 * and constants, which are primitive recursive.

Hence the result.

Note
The sum $$\sum_{y=1}^z$$ is referred to as a bounded sum to distinguish it from $$\sum_{y=1}^\infty$$ which is not.