A detailed account of the Kohn–Sham (KS) algorithm from quantum chemistry, formulated rigorously in the very general setting of convex analysis on Banach spaces, is given here. Starting from a Levy–Lieb-type functional, its convex and lower semi-continuous extension is regularized to obtain differentiability. This extra layer allows us to rigorously introduce, in contrast to the common unregularized approach, a well-defined KS iteration scheme. Convergence in a weak sense is then proven. This generalized formulation is applicable to a wide range of different density-functional theories and possibly even to models outside of quantum mechanics.