First-principles theory of structural phase transitions for perovskites: Competing instabilities | Synapse