Theory of earthquakes