The foundations of celestial mechanics