Solution (source code)

= Solution

Write the variables as $(u,v)\in\mathbb R^n\times\mathbb R^k$, with $a=(u_0,v_0)$. The hypothesis makes $D_uf(a)$ invertible. The <implicit function theorem> supplies neighbourhoods $U,V$ of $u_0,v_0$ and a unique <smooth map> $\phi:V\to U$ such that
$$
\boxed{f^{-1}(b)\cap(U\times V)=\{(\phi(v),v):v\in V\},\quad \phi(v_0)=u_0.}
$$
Its derivative is $D\phi(v_0)=-(D_uf(a))^{-1}D_vf(a)$. Thus the derivative of this parametrization has image exactly $\ker Df(a)$.

Since $h$ has a constrained maximum at $a$, differentiating $v\mapsto h(\phi(v),v)$ gives zero in every direction. Therefore $Dh(a)$ vanishes on $\ker Df(a)$. In finite-dimensional <linear algebra>, $(\ker Df(a))^\perp$ is the <row space> of $Df(a)$. Consequently
$$
\boxed{\nabla h(a)=\sum_{j=1}^n\lambda_j\nabla f_j(a).}
$$
The full-rank hypothesis is what permits this <Lagrange multiplier> conclusion; it is not a consequence of constrained maximality alone at a singular constraint.