Confronting theoretical models with the observed evolution of the galaxy population out to z= 4