For self-supervised learning, Rationality implies generalization, provably