PAC Generalization via Invariant Representations