Solution (source code)

= Solution

For a fixed alternative $0<\lambda<\lambda_0$, the joint <likelihood ratio> is
$$
\frac{L(\lambda)}{L(\lambda_0)}
=\left(\frac\lambda{\lambda_0}\right)^n
\exp\left((\lambda_0-\lambda)\sum_i x_i\right).
$$
It is strictly increasing in $S=\sum_i x_i$. By the <Neyman-Pearson lemma>, the most powerful level-$\alpha$ rejection region is therefore $S\geq c_\alpha$. Under the null, $S\sim\operatorname{Gamma}(n,\lambda_0)$ with the second parameter interpreted as a rate. Its continuous distribution gives
$$
\boxed{c_\alpha=q(1-\alpha;n,\lambda_0).}
$$
This threshold depends on the null and $\alpha$, but not on the particular smaller alternative $\lambda$. Thus the same test is most powerful for every $0<\lambda<\lambda_0$, making it <uniformly most powerful test>[uniformly most powerful].

Under a true alternative $\lambda$, $S\sim\operatorname{Gamma}(n,\lambda)$, so its attained power is
$$
\boxed{Q(\lambda)=1-F(q(1-\alpha;n,\lambda_0);n,\lambda).}
$$
For each $\lambda<\lambda_0$, the <Neyman-Pearson lemma> bounds the power of every other level-$\alpha$ test by this value. Hence the displayed function is not only an upper bound but the attainable power envelope on the specified alternative.