Theory of superconductivity. I. Electron-lattice interaction