On the Mathematics of Diffusion Models