We consider the general problem of minimizing a function $f$ on a feasible set $M$ where $M$ is given as the preimage of a constraint set $Z$ under a constraint mapping $g$, i.e., $M = g^{-1}(Z)$.This class of optimization problems includes for example nonlinear programming (NLP), mathematical programs with complementarity constraints (MPCCs) and (nonlinear) semidefinite programming (SDP). Since in practice the constraint set $Z$ is typically defined by (finitely many) polynomial \mbox{(in-)equalities} we assume that $Z$ is semialgebraic. As a main result we obtain first-order necessary optimality conditions which apply for generic constraint mappings $g$. These optimality conditions are generalizations of analog results for NLPs, MPCCs and SDPs. Thus we obtain the well-known Karush-Kuhn-Tucker (KKT) conditions for NLPs as a special case.\\ We point out that our result has implications on the development of solution algorithms. Indeed in practice - given a concrete problem instance - it is not possible to verify a constraint qualification at the (unknown) minimizer $x^*$. Our result however guarantees that the first-order necessary optimality conditions hold for ``almost all'' problem instances. This means that in practice the necessary optimality conditions typically apply at all minimizers $x^*$. |