The cohomology of the BRS operator corresponding to a group of rigid s
ymmetries is studied in a space of local field functionals subjected t
o a condition of gauge invariance. We propose a procedure based on a f
iltration operator counting the degree in the infinitesimal parameters
of the rigid symmetry transformations, An application to Witten's top
ological Yang-Mills theory is given.