In this paper, we study the problem of computing by relaxation hierarchies
the infimum of a real polynomial function f on a closed basic semialgebraic set
and the points where this infimum is reached, if they exist. We show that when
the infimum is reached, a relaxation hierarchy constructed from the
Karush-Kuhn-Tucker ideal is always exact and that the vanishing ideal of the
KKT minimizer points is generated by the kernel of the associated moment matrix
in that degree, even if this ideal is not zero-dimensional. We also show that
this relaxation allows to detect when there is no KKT minimizer. We prove that
the exactness of the relaxation depends only on the real points which satisfy
these constraints.This exploits representations of positive polynomials as
elementsof the preordering modulo the KKT ideal, which only involves
polynomials in the initial set of variables. Applications to global
optimization, optimization on semialgebraic sets defined by regular sets of
constraints, optimization on finite semialgebraic sets, real radical
computation are given