Foundations of general relativity