Twisted de Rham cohomology, homological definition of the integral and “Physics over a ring”