Theoretical Foundations of Conformal Prediction