Logic of substituting in maximization problem I assume in the following that all functions are real valued and defined on the real numbers or product spaces of the real numbers. Suppose one is given the following maximization problem: $$\max_{x,y} f(x,y)$$ such that $x+y=10$ (this is just an arbitrary constraint for the sake of an example). Suppose further that $f$ is given by $$f(x,y)=g(x)+y$$ for some function $g$. One can then also substitute the constraint equation to obtain the maximization problem $$\max_x g(x)+10-x.$$ If one finds a solution $x$ for this maximization problem, is this also a solution for the maximization problem above? If so, why is this the case?
More formally the idea should be: One wants to find elements of the set $$S:=\{(x,y) \ | \ x,y \in \mathbf{R} \wedge x+y=10 \wedge \forall p,q \in\mathbf{R}:f(p,q)\leq f(x,y)\}.$$ Suppose now $x_1$ maximizes $g(x)+10-x$ meaning that $x_1$ is an element of the set $$A:=\{x \ | \ x \in \mathbf{R} \wedge \forall z \in \mathbf{R}: g(z)+10-z \leq g(x_1)+10-x_1\}.$$ Then by setting $y_1:=10-x_1$ one obtains a pair $(x_1,y_1)$ that satisfies $$[\forall z \ g(z)+10-z \leq g(x_1)+10-x_1] \wedge [x_1 + y_1 = 10].$$ Now this implies that for all $(x,y)$ with $x+y=10$ we have $$g(x)+y=g(x)+10-x\leq g(x_1)+10-x_1=g(x_1)-y_1$$ which means that $(x_1,y_1)$ indeed maximizes $f$ under the constraint that $x_1+y_1=10$. Is this the correct reason for substitution of equations to work? A converse implication does not hold because one loses information about $y$, right?
 A: Not an answer, just some thoughts
You need to notice the feasible region. Here is an example (in a journal).
Consider the following optimization problem:
\begin{align*}
 &\max_{x,\, y} ~ - (x - 5)^2 - y^2 \tag{1}\\
 &\mathrm{s.t.}\qquad 16x = y^2.
\end{align*}
The maximizer is $x = y = 0$.
Then consider the following:
$$\max_{x} ~ - (x - 5)^2 - 16x. \tag{2}$$
The maximizer is $x = -3$.
Actually, you should consider the following:
$$\max_{x \ge 0} ~ -(x - 5)^2 - 16x. \tag{3}$$

Example 2:
Consider the following optimization problem:
\begin{align*}
 &\max_{x,\, y} ~ - (x - 5)^2 + 5\mathrm{e}^{y} + 5\mathrm{e}^{-y} \\
 &\mathrm{s.t.}\qquad x = 5\mathrm{e}^{y} + 5\mathrm{e}^{-y}.
\end{align*}
The maximizer is $x = 10, y = 0$.
Then consider the following:
$$\max_{x} ~ - (x - 5)^2 + x. $$
The maximizer is $x = 11/2$.
Actually, you should consider:
$$\max_{x\ge 10} ~ - (x - 5)^2 + x.$$
(Note: $5\mathrm{e}^{y} + 5\mathrm{e}^{-y} \ge 10$ for all $y \in \mathbb{R}$.)
That is, we need to add the constraint for $x$.
But, what if the range of $x$ is hard to determine?
For example,
\begin{align*}
 &\max_{x,\, y} ~ - (x - 5)^2 - \left(\frac45 y + \sin y - 2\ln (1 + y)\right) \\
 &\mathrm{s.t.}\qquad 12x = \frac45 y + \sin y - 2\ln (1 + y).
\end{align*}
