I am studying partial recursive functions, and while I think I understand most elements of how to prove a given function is primitive recursive, there is one particular pattern that I can't come up with a good explanation for.
Specifically, how would I show that the following function is primitive recursive?
$f(x_1, \dots, x_n, i) = x_i$
This is equivalent to a projection function $\pi_{i, n}$, but the projection function used depends on $i$, which is also a function parameter. It seems intuitive that this should be primitive recursive, and I can see that for some fixed arity you could do a definition by cases, e.g. for $ n = 2 $:
$f(x_1, x_2, i) = \begin{cases} \pi_{1,2}(x_1, x_2) &\text{if } i = 1\\ \pi_{2,2}(x_1, x_2) &\text{if } i = 2 \end{cases}$
What I'm unsure of is how to show this is true for the general case.
Note I have also seen this question, but it just defines the function; it doesn't prove it is primitive recursive.
For some context as to where this may be used, consider the summation:
$f(x_1, \dots, x_n) = \sum_{i=1}^{n} x_i$
The normal proof that a summation $\sum_{i=1}^{k} g(x_1, \dots, x_n, i)$ is primitive recursive requires proving that $g$ is primitive recursive - so for the simple case of summing up all arguments the function I'm concerned about must be shown to be primitive recursive!