It is known that the laws of thermodynamics break down when systems are correlated with their environments. In the presence of correlations, anomalous heat flows from cold to hot baths become possible, as well as memory erasure accompanied by work extraction instead of heat dissipation.
Here, we generalize thermodynamics to physical scenarios which allow presence of correlations, including those where quantum entanglements are present. We exploit the connection between information and physics, and introduce a consistent redefinition of heat dissipation by systematically accounting for the information flow from system to bath in terms of the conditional entropy. As a consequence, the formula for the Helmholtz free energy is accordingly modified. Such a remedy not only fixes the apparent violations of Landauer's erasure principle and the second law due to anomalous heat flows, but it also leads to a reformulation of the laws of thermodynamics that are universally respected.