Theory of Longitudinal Instabilities in Synchrotrons, with Applications