A Formal Learning Theory for Three-Way Clustering