Generalized laws of thermodynamics in the presence of correlations