  The exact conditions for density functionals and density matrix functionals
in terms of fractional charges and fractional spins are known, and their
violation in commonly used functionals has been shown to be the root of many
major failures in practical applications. However, approximate functionals are
not normally expressed in terms of the fractional variables. Here we develop a
general framework for extending approximate density functionals and
many-electron theory to fractional-charge and fractional-spin systems. Our
development allows for the fractional extension of any approximate theory that
is a functional of $G^{0}$, the one-electron Green's function of the
non-interacting reference system. The extension to fractional charge and
fractional spin systems is based on the ensemble average of the basic variable,
$G^{0}$. We demonstrate the fractional extension for the following theories:
(1) any explicit functional of the one-electron density, such as the LDA and
GGA; (2) any explicit functional of the one-electron density matrix of the
non-interacting reference system, such as the exact exchange functional and
hybrid functionals; (3) many-body perturbation theory; and (4) random-phase
approximations. A general rule for such an extension has also been derived
through scaling the orbitals and should be useful for functionals where the
link to the Green's function is not obvious. The development thus enables the
examination of approximate theories against known exact conditions on the
fractional variables and the analysis of their failures in chemical and
physical applications in terms of violations of exact conditions of the energy
functionals. The present work should facilitate the calculation of chemical
potentials and fundamental band gaps with approximate functionals and
many-electron theories through the energy derivatives with respect to the
fractional charge.
