\rho_q(d-j(q-1)-\ell,m-j-1) + \sum_{i=1}^b\rho_q(i,m-a-1).$$

This follows using Lemma \[lem:help\] repeatedly. First applying the lemma to each sum within the double summation on the right-hand side, we see that $$\begin{gathered}
\sum_{j=0}^{a-1} \sum_{\ell=0}^{q-2} \rho_q(d-j(q-1)-\ell,m-j-1) = \\
\sum_{j=0}^{a-1} \left( \rho_q(d-j(q-1),m-j)-\rho_q(d-(j+1)(q-1),m-j-1) \right) = \\
\rho_q(d,m)-\rho_q(d-a(q-1),m-a)  = \rho_q(d,m)-\rho_q(b,m-a).\end{gathered}$$ Using the same lemma to rewrite the single summation on the right-hand side in Equation we see that if $m>a$ $$\sum_{i=1}^b\rho_q(i,m-a-1)=\rho_q(b,m-a)-\rho_q(0,m-a-1)=\rho_q(b,m-a)-1,$$ while if $m=a$, the single summation equals $0$ and the double summation simplifies to $\rho_q(d,m)-1$. In either case, we obtain the desired result

We can now show the following.

\[thm:genrepMac\] Let $N \ge 0$ and $d \ge 1$ be integers and $q$ a prime power. Then there exist uniquely determined integers $m_1,\dots,m_d$ satisfying

1.  $N=\sum_{i=1}^d \rho_q(i,m_i),$

2.  $-1 \le m_1 \le \cdots \le m_d,$

3.  for all $i$ satisfying $1 \le i \le d-q+1$, either $m_{i+q-1} > m_i$ or $m_{i+q-1}=m_i=-1$.

We start by showing uniqueness. Suppose that $$\label{eq:uniqueness}
N=\sum_{i=1}^d \rho_q(i,m_i)=\sum_{i=1}^d \rho_q(i,n_i)$$ and the integers $n_1,\dots,n_d$ and $m_1,\dots m_d$ satisfy the conditions from the theorem. First of all, if $m_d=-1$ or $n_d=-1$ then $N=0$. Either assumption implies that $(m_d,\dots,m_1)=(-1,\dots,-1)=(n_d,\dots,n_1)$. Indeed $n_i\ge 0$ or $m_i \ge 0$ for some $i$ directly implies that $N>0$. Therefore we from now on assume that $m_d\ge 0$ and $n_d \ge 0$. To arrive at a contradiction, we may assume without loss of generality that $n_d \le m_d-1$.

Define $e$ to be the smallest integer such that $n_e \ge 0$. Equation can then be rewritten as $$\label{eq:uniqueness1}
N=\sum_{i=1}^d \rho_q(i,m_i)=\sum_{i=e}^d \rho_q(i,n_i)$$ Condition 3 from the theorem implies that $n_{i-q+1}<n_i$ for all $i$ satisfying $e \le i \le d $. Now write $d-e+1=a(q-1)