  We present a common framework to study varieties in great generality from a
categorical point of view. The main application of this study is in the setting
of algebraic categories, where we introduce Birkhoff varieties which are
essentially subvarieties of algebraic categories, and we get a generalization
of Birkhoff's variety theorem. In particular, we show that Birkhoff varieties
are coreflexive equalizers. The key of this generalization is to give a more
general concept of equation for subvarieties of algebraic categories. In order
to get our characterization of Birkhoff varieties, we study inserters over
algebraic categories, where we generalize some well-known results of algebras
for finitary endofunctors over $Set$. By duality, we obtain a characterization
of cosubvarieties of coalgebraic categories. Surprisingly, these cosubvarieties
turn to be varieties according to our theory of varieties.
