An irreducibility criterion for group representations, with arithmetic applications