We define a systematic strategy for the calculation of exact density functionals. It consists in coding the information about the density and the energy into polynomials of the degrees of freedom of the wave functions under consideration. Density functionals are then obtained by standard elimination procedures of such degrees of freedom between the polynomials. The theory is illustrated by numerical examples.