Theory of phase transitions