There's a theorem that says that if $C \subset \mathbb R^n$ is a convex set, then $x^* \in C$ is the closest point in $C$ to $y \notin C$ if and only if $(y-x^*)\cdot(x-x^*)\leq 0$ for all $x \in C$.
I have a proof for this theorem but I am unsure of its validity.
My Proof:
Suppose $x^*$ is the closest point from $C$ to $y$. For each $x \in C$ we define a function $\phi: [0,1] \to \mathbb R$ $\phi(t) = ||y-(x^*+t(x-x^*))||^2$
Since $C$ is convex we know that $x^*+t(x-x^*) \in C$ for all $t \in [0,1]$, and so from our assumption that $x^*$ is closest to $y$, we can infer that $t=0$ is a minimum of $\phi(t)$. This is because $\phi(0)=||y-x^*||^2$ which we assumed is minimal. So after $t_0=0$ this function increases (or at least it does not decrease), so $\phi'(0)\geq 0$
If we derive we get $\phi'(t) = -2(y-(x^*+t(x-x^*)))\cdot(x-x^*)$, and so $\phi'(0) = -2(y-x^*)\cdot(x-x^*)$ which we know is not negative, and so we can divide by $-2$ to get the desired result which is $(y-x^*)\cdot(x-x^*) \leq 0$
My problem
$\phi(t)$ is defined on the interval $[0,1]$. Can we really speak of the derivative at $0$? right side limit sure, but derivative? I'm not completely sure of this proofs validity but I don't have any better idea.
Edit Just in case someone is interested of the proof of the other direction which im quite positive is correct:
Assume $(y-x^*)\cdot(x-x^*)\leq 0$ for all $x \in C$ and define $d(x)=||y-x||^2$. then $\nabla d(x) = -2(y-x^*)$ and $Hd(x) = 2I$ and so $d$ is convex.
So that means that $d(x) \geq d(x^*)+\nabla d(x^*)\cdot(x-x^*)$. This is a known property of convex functions. and since $\nabla d(x^*) = -2(y-x^*)$ we get that $d(x) \geq d(x^*)-2(y-x^*)\cdot (x-x^*) \geq d(x^*)$. The last inequality is true since we assumed $(y-x^*)\cdot (x-x^*) \leq 0$ and so $-2(y-x^*)\cdot (x-x^*) \geq 0$ and so $d(x^*)-2(y-x^*)\cdot (x-x^*) \geq d(x^*)$.
So overall $d(x) \geq d(x^*)$, so $x^*$ is the closest point in $C$ to $y$.
The proof is correct. As was mentioned, it is sufficient to deal with the limit.