I am attempting to solve part (ii) of the following problem:
Let $V$ be a region in $\Bbb{R}^3$ with boundary a closed surface $S$. Consider a function $\phi$ defined in V that satisfies $$\nabla^2\phi - m^2\phi = 0$$ for some constant $m\ge0$.
(i) If $\frac{\delta\phi}{\delta n}=g$ on $S$, for some given function $g$, show that $\phi$ is unique provided that $m \gt 0$. Does this conclusion change if $m = 0$?
[Recall: $\frac{\delta}{\delta n} = \mathbf{n}\cdot\nabla$, where $\mathbf{n}$ is the outward pointing unit normal on $S$]
(ii) Now suppose instead that $\phi = f$ on $S$, for some given function $f$. Show that for any function $\psi$ with $\psi$ = f on $S$, $$\int_V \left( \lvert \nabla\psi \rvert^2 + m^2\psi^2 \right)dV \ge \int_V \left( \lvert \nabla\phi \rvert^2 + m^2\phi^2 \right)dV$$
What is the condition for equality to be achieved, and is this result sufficient to deduce that $\phi$ is unique? Justify your answers, distinguishing carefully between the cases $m \gt 0$ and $m = 0$.
Here is my attempt so far:
$$\int_V \nabla \cdot \left( \phi \nabla \phi \right)dV = \int_V \left( \nabla\phi\cdot\nabla\phi + \phi\nabla^2\phi \right)dV = \int_V \left( \lvert \nabla\phi \rvert^2 +m^2\phi^2 \right)dV$$
and using the Divergence theorem, $$\int_V \nabla \cdot \left( \phi \nabla \phi \right)dV = \int_S \phi\nabla\phi\cdot d\mathbf{S} = \int_S f\nabla f \cdot d\mathbf S$$
Since $\phi=\psi=f$ on $S$, we can use the Divergence theorem on $\psi$ to deduce that
$$\int_V \left( \lvert \nabla\phi \rvert^2 +m^2\phi^2 \right)dV = \int_V \left( \lvert \nabla\psi \rvert^2 +\psi\nabla^2\psi \right)dV \tag{1}\label{eq1}$$
At this point I am a little stuck on how to continue. I tried using Green's second identity which yielded
$$\int_V \left( \phi\nabla^2\psi - \psi\nabla^2\phi \right)dV = \int_S \left( \phi\nabla\psi - \psi\nabla\phi \right) \cdot d\mathbf S = 0$$ $$\implies \int_V \phi\nabla^2\psi dV = \int_V \psi\nabla^2\phi dV = \int_V m^2\psi\phi dV$$ $$\implies \int_V \phi\left( \nabla^2\psi -m^2\psi \right) dV = 0$$ I did not see how this would be of use, so instead I applied the Divergence theorem to $\nabla^2\psi$ to obtain $$\int_V \nabla^2 \psi dV = \int_V \nabla \cdot \nabla\psi dV = \int_S \nabla\psi\cdot d\mathbf S = \int_S \nabla\phi\cdot d\mathbf S = \int_V \nabla^2 \phi dV = \int_V m^2 \phi dV$$
Using this, $\eqref{eq1}$ becomes
$$\int_V \left( \lvert \nabla\phi \rvert^2 +m^2\phi^2 \right)dV = \int_V \left( \lvert \nabla\psi \rvert^2 +\psi\nabla^2\psi \right)dV = \int_V \left( \lvert \nabla\psi \rvert^2 + m^2\psi\phi \right)dV$$
This feels like I am close to the result now but am unable to see how to proceed. Any hints would be appreciated, thanks.
Btw, what you wrote is not the Klein-Gordon equation (that would require an extra term $-\partial_t^2\phi$).
First of all, I should mention that in your work, you’re making the fatal mistake of thinking that just because $\psi=\phi=f$ on the boundary $\partial\Omega$, that it would imply $\frac{\partial\psi}{\partial n}=\frac{\partial \phi}{\partial n}$ too. This is completely wrong! Having two functions equal on the boundary tells you nothing about their normal derivatives; all you can conclude is that their tangential derivatives are equal (i.e for any tangent vector $\mathbf{t}$ to $\partial\Omega$, $\nabla\phi\cdot \mathbf{t}=\nabla\psi\cdot\mathbf{t}$ on $\partial\Omega$).
Anyway, this is a classic problem regarding minimization and Dirichlet’s principle (though that is usually stated for the Laplacian only). Let $\Omega\subset\Bbb{R}^n$ be a bounded open set with $C^1$ boundary $\partial\Omega$. Fix a continuous function $f:\partial\Omega\to\Bbb{R}$, and consider the collection of functions $\mathcal{D}_f=\{\psi\in C^2(\overline{\Omega})\,:\,\psi|_{\partial\Omega}=f\}$, i.e the functions whose boundary values equal $f$. Next, consider the functional $I$ which takes any $C^1$ function $\psi$ on $\Omega$ and produces the number \begin{align} I[\psi]&:=\frac{1}{2}\int_{\Omega}\left(|\nabla\psi|^2+m^2\psi^2\right)\,dV. \end{align} This is called the Dirichlet (energy) integral or something to that effect. Notice that $I[\psi]\geq 0$ for all $\psi$, and if $m>0$ then it is clear that $I[\psi]=0$ if and only if $\psi=0$. On the other hand, if $m=0$ then $I[\psi]=0$ if and only if $\nabla\psi=0$ i.e if and only if $\psi$ is constant on connected components of $\overline{\Omega}$; in particular if $\phi,\psi\in\mathcal{D}_f$ and $I[\phi-\psi]=0$ then $\phi-\psi$ is constant on connected components of $\overline{\Omega}$, but since $\phi|_{\partial\Omega}=\psi|_{\partial\Omega}=f$, these constants are $0$, i.e $\phi=\psi$.
Dirichlet’s principle states that a function $\phi\in \mathcal{D}_{f}$ satisfies the equation $\nabla^2\phi-m^2\phi=0$ if and only if it is a global minimum point for the functional $I$ on $\mathcal{D}_f$ (i.e for all $\psi\in\mathcal{D}_f$, $I[\phi]\leq I[\psi]$… and in the proof we shall see what the equality condition is).
For now, let us just do some calculation. Consider any two functions $\phi,\psi\in\mathcal{D}_f$ (I make no assumption about any PDE they satisfy). Let us denote $\zeta:=\psi-\phi$. In particular, this means $\zeta|_{\partial\Omega}=0$. Now, some simple algebra and the divergence theorem tells us \begin{align} I[\psi]&= I[\phi+\zeta]\\ &=\frac{1}{2}\int_{\Omega}\left(|\nabla\phi+\nabla\zeta|^2+m^2(\phi+\zeta)^2\right)\,dV\\ &=\frac{1}{2}\int_{\Omega}\left(|\nabla\phi|^2+2\nabla\phi\cdot\nabla\zeta+|\nabla\zeta|^2+m^2\phi^2+2m^2\phi\zeta+m^2\zeta^2\right)\,dV\\ &=I[\phi]+I[\zeta]+\int_{\Omega}\left(\nabla\phi\cdot\nabla\zeta+m^2\phi\zeta\right)\,dV\\ &=I[\phi]+I[\zeta]+\int_{\partial\Omega}\frac{\partial\phi}{\partial n}\zeta\,dA+\int_{\Omega}\left(-\nabla^2\phi+m^2\phi\right)\zeta\,dV\\ &=I[\phi]+I[\zeta]+0+\int_{\Omega}\left(-\nabla^2\phi+m^2\phi\right)\zeta\,dV, \end{align} where in the penultimate step I used the divergence theorem, and in the final step I used the fact that $\zeta$ vanishes on the boundary. So, we can write this identity as: for all $\phi,\psi\in\mathcal{D}_f$, \begin{align} I[\psi]&=I[\phi]+I[\psi-\phi]+\int_{\Omega}\left(-\nabla^2\phi+m^2\phi\right)(\psi-\phi)\,dV.\tag{$*$} \end{align} Ok, so now we can get to work. Suppose $\phi\in\mathcal{D}_f$ satisfies the PDE. Then, the integral term in $(*)$ vanishes and we see that for all $\psi\in\mathcal{D}_f$, we have $I[\psi]=I[\phi]+I[\psi-\phi]\geq I[\phi]$, and we have equality if and only if $I[\psi-\phi]=0$, which happens if and only if $\psi=\phi$.
The converse statement that if $\phi\in\mathcal{D}_f$ minimizes $I$ then it satisfies the PDE is a standard exercise in calculus of variations. To prove this, let $\zeta\in C^{\infty}_c(\Omega)$. Consider the function of one variable $g(\epsilon)=I[\phi+\epsilon\zeta]$. By hypothesis (notice that for each $\epsilon$ the function $\phi+\epsilon\zeta$ belongs to $\mathcal{D}_f$), the function $g$ has a minimum point at $\epsilon=0$. Since $g$ is also differentiable (it is simply a quadratic polynomial in $\epsilon$), it follows $g’(0)=0$ by basic calculus. So, \begin{align} 0&=g’(0)\\ &=\frac{d}{d\epsilon}\bigg|_{\epsilon=0}\frac{1}{2}\int_{\Omega}\left(|\nabla\phi+\epsilon\nabla\zeta|^2+m^2|\phi+\epsilon\zeta|^2\right)\,dV\\ &=\int_{\Omega}\nabla\phi\cdot\nabla\zeta+m^2\phi\zeta\\ &=\int_{\Omega}\left(-\nabla^2\phi+m^2\phi\right)\zeta\,dV, \end{align} where I used the divergence theorem in the last step, and since $\zeta$ has compact support, the boundary term vanishes. Since $\zeta$ was arbitrary, the fundamental lemma of calculus of variations implies that $-\nabla^2\phi+m^2\phi=0$ on $\Omega$.