Towards Theoretical Foundations of Clustering