A relaxation theorem and its application to the equilibrium of gases