Theory of solidification