  We formulate a theory of instability and Harder-Narasimhan filtrations for an
arbitrary moduli problem in algebraic geometry. We introduce the notion of a
$\Theta$-stratification of a moduli problem, which generalizes the Kempf-Ness
stratification in GIT as well as the Harder-Narasimhan stratification of the
moduli of coherent sheaves on a projective scheme. Our main theorems establish
necessary and sufficient conditions for the existence of these stratifications.
We define a structure on an algebraic stack called a numerical invariant, and
we show that in many situations a numerical invariant defines a
$\Theta$-stratification on the stack, assuming a certain "HN boundedness"
condition holds. We also discuss criteria under which the semistable locus has
a moduli space. We apply our methods to an example that lies beyond the reach
of classical methods: the stratification of the stack of objects in the heart
of a Bridgeland stability condition.
