Let $\mathcal X$ be some compact subset of $\mathbb R^d$, and define $(\mathcal M(\mathcal X),\|\cdot\|) $ to be the space of bounded and real-valued measurable functions on $\mathcal X $, equipped with the supremum norm $\|\cdot\| $.
Let $\mathcal F \subset \mathcal M(\mathcal X)$ be a closed subset of functions defined on $\mathcal X$. For my purposes, I can't assume that $\mathcal F$ has much of a nice structure : it is not a vector space, and it is not convex either. But if that can help I am okay with initially relaxing this requirement.
Now, let $J: \mathcal M(\mathcal X)\to\mathbb R^+$ be a cost functional and assume we want to minimize it over the family of functions $\mathcal F$. In other words, we want to solve $$\min_{f\in\mathcal F}{J(f)} \tag 1$$ Furthermore, assume that there exists a unique function $f^*$ that minimizes $J$ over all functions in $\mathcal M(\mathcal X)$ : $$f^* := \arg\min_{f\in\mathcal M(\mathcal X)} J(f)$$
Intuitively, one would think that if $J$ is well-behaved enough (e.g. convex, smooth...), minimizing $J$ over $\mathcal F$ is equivalent to finding the function $f\in\mathcal F$ that best approximates $f^*$, i.e. that solving problem $(1)$ is equivalent to solving the following : $$\min_{f\in\mathcal F} \|f-f^*\| \tag2 $$ The two problems are clearly related (see this nice blog post which inspired this question), but are they actually equivalent ? More rigorously, I want to know under what (minimal) assumptions on $J$ the following statement is true : $$f\in\left\{\arg\min_{f\in \mathcal F} J(f)\right\}\iff f\in\left\{\arg\min_{f\in \mathcal F} \|f-f^*\|\right\} \tag3$$ I am especially interested in the direction $\Rightarrow$, though of course I will take any hints or references that would help for either direction.
My thoughts : I initially thought (hoped) that $J$ being convex would be sufficient for the result to hold, but it is actually not the case, as highlighted by the following counterexample :
Let $J$ be the "$1$-norm" :
$$\|f\|_1\equiv J(f):=\begin{cases}\sup_{x\in\mathcal X} |f(x)| + |f'(x)| \text{ if } f\in C^1(\mathcal X),\\
+\infty \text{ otherwise}\end{cases} $$
Then clearly the global minimizer of $J$ is the $0$ function but it is possible to find functions with arbitrarily large $\|\cdot\|_1$ norm and arbitrarily small $\|\cdot\|_\infty$ norm. So, for instance, if I let $\mathcal X\equiv[0,1]\subseteq \mathbb R^1$, and let
$$\mathcal F =\{x\mapsto\varepsilon\sin(Mx),x\mapsto (\varepsilon/2)\sin(M^2 x)\mid \varepsilon\in[1/2,1],M\ge10^6\} $$
Then the minimizer of $J$ over $\mathcal F$ is $\phi :x\mapsto \frac{1}{2}\sin(10^6 x)$, but the map $\varphi :x\mapsto \frac{1}{4}\sin(10^{12} x)\in\mathcal F$ is closer to the zero function in supremum norm.
In this example, $\mathcal F$ is particularly badly behaved, but I think similar counterexamples can be found for "nicer" sets too.
Either way, $J$ being convex is not enough, but I suspect that additional regularity assumptions such as Lipschitz continuity could do the trick. I haven't been able to prove it though...