Consider the finite-dimensional Hilbert space $\mathbb{R}^N$ equipped with the scalar product $\langle \cdot,\cdot \rangle$ that induces $l_2$-norm $||\cdot||_2$. Let $S \subset \mathbb{R}^N$ and $\mathcal{P}_S$ be a projection onto $S$. That is
$\mathcal{P}_S(x)=argmin_{y\in\mathcal{S}} ||y-x||_2$.
Show that if $\mathcal{P}_S$ satisfies
$\langle z-\mathcal{P}_S(x),x-\mathcal{P}_S(x) \rangle \le 0$ $\forall x \in \mathbb{R}^N, z \in S$
then $S$ is already convex.
What I have tried so far:
Let $a,b\in \mathbb{R}$ and $\lambda \in [0,1]$ and $\tilde x = \lambda a + (1-\lambda)b$. Then:
$\langle z-\mathcal{P}_S(\tilde x), \tilde x-\mathcal{P}_S(\tilde x) \rangle \le 0$ $\forall z \in S$.
Fix $z=0$ and the inequality becomes
$\langle -\mathcal{P}_S(\tilde x), \tilde x-\mathcal{P}_S(\tilde x) \rangle \le 0$
$\langle \mathcal{P}_S(\tilde x), \mathcal{P}_S(\tilde x) \rangle \le \langle \mathcal{P}_S(\tilde x), \tilde x \rangle$.
And now I'm stuck. Any help is highly appreciated, thanks.
Suppose $(x, y) \in \operatorname{graph} \mathcal{P}_S$. Let $$H_{(x, y)} = \{ z \in \mathbb{R}^n : \langle z - y, x - y\rangle \le 0 \}.$$ Note that $H_{(x, y)}$ is closed and convex (and a half-space). I claim that $$S = \bigcap_{(x, y) \in \operatorname{graph} \mathcal{P}_S}H_{(x, y)},$$ hence $S$ is closed and convex. Note that, from the inequality, we have $\subseteq$, so we just need to show $\supseteq$.
Suppose $w \in \bigcap_{(x, y) \in \operatorname{graph} \mathcal{P}_S}H_{(x, y)}$. Let $v \in \mathcal{P}_S(w)$. Then, $$w \in H_{(w, v)} \implies \langle w - v, w - v \rangle \le 0 \implies w = v \in S.$$ Done!