The bounded sum is a primitive recursive function? Let $f:\mathbb{N}^{p+1} \to \mathbb{N}$ a primitive recursive function and $g:\mathbb{N}^{p+1} \to \mathbb{N}$ the bounded sum defined by : $g(\bar{a},x)=\sum\limits_{i=0}^x f(\bar a , i)$.
To show that $g$ is  a primitive recursive function we want to show that $g$ is closed under the primitive recursion :
$g(\bar a, 0)= f(\bar a ,0)= k(\bar a)$ where $k$ is a primitive recursive function because of $f$.
$g(\bar a, x+1) = g(\bar a , x) + f(\bar a,x+1)$ which is the sum of two recursive primitive functions (addition is also a recursive primitive operation).
But if we want to find explicitly a recursive primitive function $h$ such that : $g(\bar a, x+1) = h(\bar a, x ,g(\bar a, x))$ which $h$ should we take ?
I mean how can we make appear $f(\bar a , x+1)$ in $h$ ? As $f$ is primitive recursive we can write : $f(\bar a , x+1)= h'(\bar a, x, f(\bar a, x))$ hence $g(\bar a, x+1) = g(\bar a , x) + h'(\bar a, x, f(\bar a, x))$ but then I am stuck...
Thanks in advance !
 A: When you say
$$g(\bar a, x+1) = g(\bar a , x) + f(\bar a,x+1)$$
is primitive recursive as it is the sum of two primitive recursive functions , you are assuming that $g(\bar a , \cdot)$ is a primitive recursive function, where I am using the $\cdot$ as a place-holder for the unknown argument of $g$. This doesn't work, because we are trying to show that $g(\bar a, \cdot)$ is primitive recursive and we don't have that as any kind of inductive hypothesis.
Instead, look at the desired relationship between $g(\bar a, x+1)$ and $g(\bar a , x)$, namely:
$$g(\bar a, x+1) = \sum\limits_{i=0}^{x+1} f(\bar a , i) = g(\bar a, x) + f(\bar a, x +1)$$
So to get $g(\bar a, x+1) = g(\bar a , x) + f(\bar a,x+1)$ from the primitive recursion formula, what you need is:
$$h(\bar a, x, g(\bar a, x)) = g(\bar a, x) + f(\bar a, x+ 1)$$
But then if we think of $g(\bar a, x)$ as an unknown $y$, if we can find a primitive recursive $h$ such that :
$$h(\bar a, x, y) = y + f(\bar a, x+ 1)$$
we are done, because the above defines an $h$ that is primitive recursive if $f$ is (which is given), and combined with your approach to the function $k$ needed in the base case $x = 0$, you can prove by induction that the resulting primitive recursive function defined by $k$ and $h$ gives the sum $\sum\limits_{i=0}^x f(\bar a , i)$for all $\bar a$ and $x$.
