  In this paper we derive structure theorems that characterize the spaces of
linear and non-linear differential operators that preserve finite dimensional
subspaces generated by polynomials in one or several variables. By means of the
useful concept of deficiency, we can write explicit basis for these spaces of
differential operators. In the case of linear operators, these results apply to
the theory of quasi-exact solvability in quantum mechanics, specially in the
multivariate case where the Lie algebraic approach is harder to apply. In the
case of non-linear operators, the structure theorems in this paper can be
applied to the method of finding special solutions of non-linear evolution
equations by nonlinear separation of variables.
