1: \begin{abstract}
2: The problem of characterizing a real polynomial $f$ as a sum of squares of polynomials on a real algebraic variety $V$ dates back to the pioneering work of Hilbert in \cite{hilbert1888darstellung}.
3: In this paper, we investigate this problem with a focus on cases where the real zeros of $f$ on $V$ are singular points of $V$.
4: By using optimality conditions and irreducible decomposition, we provide a positive answer to the following essential question of polynomial optimization: \emph{Are there always exact semidefinite programs to compute the minimum value attained by a given polynomial over a given real algebraic variety?}
5: Our answer implies that Lasserre's hierarchy, which is known as a bridge between convex and non-convex programs with algebraic structures, has finite convergence not only in the generic case but also in the general case.
6: As a result, we constructively prove that \emph{each hyperbolic program is equivalent to a semidefinite program}.
7: \end{abstract}
8: