Consider a general convex optimization problem: \begin{equation*} \begin{aligned} & \underset{x}{\text{minimize}} & & f_0(x) \\ & \text{subject to} & & f_i(x) \leq 0, \; i = 1, \ldots, m. & & h_i(x) = 0, \; i = 1, \ldots, p. \end{aligned} \end{equation*} of finding an $x$ that minimizes the objective function among all $x$ that satisfy the inequality ($f_i:R^n\to R$) and equality ($h_i:R^n\to R$) constraints. Suppose $x\in R^n$ (optimization variable) and $f_0:R^n\to R$ (objective function). Let $X$ denote the feasible set, i.e., $$X = \{x | f_i(x) \leq 0, i = 1, . . . ,m, h_i(x) = 0, i = 1, \dots, p\}.$$ Suppose $f_0$ is differentiable. Then it can be proved that $x$ is optimal iff $x\in X$ and $$\nabla f_0(x)^T(y - x) \geq 0\text{ for all } y\in X$$ Given this, I want to prove that for an unconstrained problem (i.e., $m = p = 0$), the above condition reduces to $$\nabla f_0(x) = 0$$ Here is the proof according to "Convex Optimization - Boyd and Vandenberghe" book:
Suppose x is optimal, which means here that $x \in domf_0$, and for all feasible $y$ we have $\nabla f_0(x)^T(y - x) \geq 0$. Since $f_0$ is differentiable, its domain is (by definition) open, so all $y$ sufficiently close to $x$ are feasible. Let us take $y = x-t\nabla f_0(x)$, where $t \in R$ is a parameter. For $t$ small and positive, $y$ is feasible, and so $\nabla f_0(x)^T (y - x) = -t||\nabla f_0(x)||^2\geq 0$, from which we conclude $\nabla f_0(x)=0$.
What I don't understand here is why any $y$ near $x$ is feasible. Since $domf_0$ is an open set, I am convinced that any $y$ near $x$ is in $domf_0$. But this doesn't mean that $y\in X$ since $domf_0 \subseteq X$ does not hold in general. So we need to find another way. The feasible set is a subset of the problem's domain: $$X\subseteq D \text{ where } D=\bigcap\limits_{i=0}^mdomf_i\bigcap\limits_{i=0}^pdomh_i$$ If we can prove that $X$ is open then any $y$ near $x$ is in $X$. Finally, is the final inequality at the end of the proof true? It doesn't affect the result but shouldn't it be: $$-t||\nabla f_0(x)||^2\leq 0\ \ \ \ ?$$