Generalized Stokes' theorem